# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def maxDepth(self, root):
"""
:type root: TreeNode
:rtype: int
"""
#深度遍历 每次递归返回较深的一侧 +1
if root is None:
return 0
l = self.maxDepth(root.left)
r = self.maxDepth(root.right)
return l>r and l+1 or r+1