Solve a problem involving binary trees, such as finding the depth of a binary tree. Represent each node as a dictionary with val, left, and right keys, using null for missing children. Implement max_depth(root) to return the number of nodes on the longest path from the root to a leaf. Return 0 when root is null.
val, left, and rightleft and right are either null or valid child nodesdef max_depth(root):