Find cheapest common ancestor in a tree | Google Coding Question