Least common ancestor, representing trees in Python, post-order traversal