spoj LCA: finding lowest common ancestor of two nodes in a tree