lowestCommonAncestor

The lowest (deepest) node that is an ancestor of both this node and other, where every node is considered an ancestor of itself.

Nodes are compared by identity (===), so this only returns a node when both arguments live in the same tree.

Return

the lowest common ancestor, or null when the two nodes belong to different trees and therefore share no common ancestor.

Runs in O(da + db) time and O(da + db) space, where da/db are the depths of the two nodes.

Parameters

other

the other node to find the common ancestor with.