```
from collections import deque
class Solution(object):
def levelOrder(self, root):
"""
:type root: TreeNode
:rtype: List[List[int]]
"""
if root is None:
return []
res = []
queue = deque()
p = root
queue.append(p)
while queue:
s = len(queue)
level_nodes = []
while s:
p = queue.popleft()
if p.left:
queue.append(p.left)
if p.right:
queue.append(p.right)
s -= 1
level_nodes.append(p)
res.append(level_nodes)
return res
```

Thank you very much!