Find Lowest Common Ancestor in a Binary Tree
Given a binary tree and two of its nodes, find their lowest common ancestor (LCA).
Implement the function
lowestCommonAncestor(root, node1, node2), where
root is the root node of the binary tree. The function should return the value of the LCA node.
Consider the following binary tree as an example, where is the LCA of and :