水题
"""
# Definition for a Node.
class Node(object):
def __init__(self, val, children):
self.val = val
self.children = children
"""
class Solution(object):
def preorder(self, root):
"""
:type root: Node
:rtype: List[int]
"""
ans = []
if root:
ans.append(root.val)
for child in root.children:
ans += self.preorder(child)
return ans