```
class Solution(object):
def levelOrder(self, root):
if root == None:
return []
levelstack = [root]
answer = []
while len(levelstack) > 0:
temp = []
tempval = []
for node in levelstack:
tempval.append(node.val)
if node.left:
temp.append(node.left)
if node.right:
temp.append(node.right)
levelstack = temp
answer.append(tempval)
return answer
```