Straightforward one pass, O(H) space
IntuitionAs long as, left depth == right depth, it should be the "local" answer.
post order helps find the global answer.Code
# Intuition
As long as, left depth == right depth, it should be the "local" answer.
post order helps find the global answer.

# Code
```python3 []
class Solution:
    def subtreeWithAllDeepest(self, root: Optional[TreeNode]) -> Optional[TreeNode]:
        def dfs(node, depth=0):
            if not node: return (node, depth)
            ansL, depthL = dfs(node.left, depth+1)
            ansR, depthR = dfs(node.right, depth+1)
            if depthL == depthR: return (node, depthL)
            if depthL > depthR: return (ansL, depthL)
            return (ansR, depthR)
        return dfs(root)[0]

```
['Python3']