
In a Meta mobile UI hierarchy, each view is a node in a rooted tree. Given the root of the view tree and two target views, return their lowest common ancestor: the deepest view that is an ancestor of both targets.
If either target view does not exist in the tree, return None.
Implement a function:
root (root ViewNode), view1 (ViewNode), view2 (ViewNode)ViewNode representing the lowest common ancestor, or NoneEach node has:
id: unique integer identifierchildren: list of child ViewNode objectsExample 1
Input: tree with 1 -> [2, 3], 2 -> [4, 5], 3 -> [6], view1 = 4, view2 = 5
Output: 2
Explanation: Both views are under node 2, and no deeper common ancestor exists.
Example 2
Input: same tree, view1 = 4, view2 = 6
Output: 1
Explanation: The paths are 1->2->4 and 1->3->6, so the root is their lowest common ancestor.
1 <= number of views <= 10^5idview1 and view2 may be the same node