# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution(object):
def maxDepth(self, root):
"""
:type root: TreeNode
:rtype: int
"""
result = []
def depth(node, maxHeight):
if node and node.left:
depth(node.left, maxHeight+1)
if node:
result.append(maxHeight+1)
if node and node.right:
depth(node.right, maxHeight+1)
result.append(maxHeight)
depth(root, 0)
# print(result)
return max(result)