Lowest Common Ancestor of a Binary Tree
Given the root and two node references p and q that both exist in the tree, find their lowest common ancestor, the deepest node that has both p and q as descendants (a node can be its own descendant).
Recurse into both children: if a node's search returns something from both sides, that node is the LCA; otherwise, pass up whichever side found something.
lowestCommonAncestor(root, p, q).val;