Pine Labs models certain payment workflow relationships as a binary tree. Given the root of a binary tree and two distinct node values, find their lowest common ancestor (LCA), the deepest node that is an ancestor of both target nodes.
Implement lca(root, p, q) and return the LCA node's integer value. Each node is represented as a dictionary with a unique value key and optional left and right child dictionaries. Both target values are guaranteed to exist in the tree.
root, a nested dictionary representing the binary tree, and integers p and q representing target node values.p and q.def lca(root, p, q):