# 429. N-ary Tree Level Order Traversal

{% embed url="<https://leetcode.com/problems/n-ary-tree-level-order-traversal/>" %}

```python
"""
# Definition for a Node.
class Node:
    def __init__(self, val=None, children=None):
        self.val = val
        self.children = children
"""

class Solution:
    def levelOrder(self, root: 'Node') -> List[List[int]]:
        res, q = [], collections.deque([root])
        if not root: return res
        while q:
            w, record, level = len(q), [], []
            for _ in range(w):
                cur = q.popleft()
                record.append(cur.val)
                if cur.children:
                    level.extend(cur.children)
            res.append(record)
            q.extend(level)
        return res
        
```
