589. N-ary Tree Preorder Traversal
Python
class Solution:
def preorder(self, root: 'Node') -> List[int]:
def travel(node, result):
if not node:
return
result.append(node.val)
for child in node.children:
travel(child, result)
result = []
travel(root, result)
return result