How do you find the lowest common ancestor of two nodes in a binary tree?
Search for both nodes at once. Recurse into the left and right subtrees. If one target is found in each subtree, the current node is their lowest common ancestor. If both targets are in the same subtree, that subtree's answer bubbles up, and if the current node is one of the targets, it is the answer by definition.
The definition matters here. The lowest common ancestor is the deepest node that has both targets as descendants, and a node counts as its own descendant. That is why the base case returns the current node when it matches either target.
The mechanism is that the recursive call returns either the answer or nothing, and the current node combines the two results. When both sides produce a node, the current node is the first point where the two paths diverge, which is exactly the definition. When only one side produces a node, that node is the answer and it is passed up unchanged.
The trade-off to name is that this works on any binary tree, including one that is not a search tree, and it costs linear time with linear space for the recursion stack. On a search tree you can do better, because the ordering tells you which side each target lives in, so a single descent finds the answer in time proportional to the height. For a tree with very many nodes and frequent queries, precomputing the answer for every pair of nodes is another option, at the cost of quadratic space.