class Solution:

    def preorder(self, root: 'Node') ->List[int]:
        if root is None:
            return []
        nodes = []
        nodes.append(root.val)
        for child in root.children:
            nodes.extend(self.preorder(child))
        return nodes

a6046a5069e102efd73ae0c96c54f70b8ba1a539
<mask token>

class Solution:
    <mask token>

class Solution:

    def preorder(self, root: 'Node') ->List[int]:
        if root is None:
            return []
        nodes = []
        nodes.append(root.val)
        for child in root.children:
            nodes.extend(self.preorder(child))
        return nodes
