Lowest Common Ancestor of a Binary Tree (LeetCode 236).
Asked in the Round 3 HM stage. Given a binary tree with unique integer values and two existing node values p and q, return the value of their lowest common ancestor. A node may be an ancestor of itself.
Implement lowest_common_ancestor(root, p, q). root is a nested dictionary with val, left, and right keys, where an absent child is null. Return the ancestor's integer value.
def lowest_common_ancestor(root, p, q):