# [[binary-tree|Binary Tree]] Level Order [[tree-traversal|Traversal]]
## Solution 1: Iteration
https://leetcode.com/problems/binary-tree-level-order-traversal/
```python
if not root:
return []
queue = [root, None] # None marks end of a level
ans = [[]]
while True:
node = queue.pop(0)
if not node:
if not queue:
break
ans.append([])
queue.append(None)
continue
ans[-1].append(node.val)
if node.left:
queue.append(node.left)
if node.right:
queue.append(node.right)
return ans
```
## Solution 2: Recursion
Intuition: use the `levels` as index to process multiple levels at the same time.
```python
levels = []
if not root:
return levels
def helper(node, level):
# start the current level
if len(levels) == level:
levels.append([])
# append the current node value
levels[level].append(node.val)
# process child nodes for the next level
if node.left:
helper(node.left, level + 1)
if node.right:
helper(node.right, level + 1)
helper(root, 0)
return levels
```