```
# 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
"""
mylist = []
if root: mylist.append(root)
lv = 0
while mylist:
lv += 1
tmp = []
for node in mylist:
if node.left: tmp.append(node.left)
if node.right: tmp.append(node.right)
mylist, tmp = tmp, mylist
return lv
```