You don't get too greedy. Usually there's a reason why bubbles form (e.g. a housing shortage in SF and London, gentrification of a certain area in a certain city etc) and often there are secondary factors as well.
Having both a clear exit price and timeframe in mind when buying is probably a good way to do it. Even if a property bubble starts to collapse, there is usually still sufficient time to get out.