Find lowest common ancestor (LCA).
Anonimo
In pseudocode: input x,y (they are the 2 nodes) ------- node A; node B; /* Put the nodes taller than the other, in var B e the other one in var A */ if(h(A) h(A);i--) { B=p(B); } /* take the parent while the 2 nodes are the same */ do { A=p(A); B=p(B); } while(A!=B); return A; (or B)