def visit(self, node, is_leaving):
    if (not is_leaving):
        self.flat_node[node] = node
        return
    if (isinstance(node, Node) and (node.kind == NT.STMTLIST)):
        children = []
        for a in node.args:
            c = self.flat_node[a]
            if (c.kind == NT.STMTLIST):
                children.extend(c.args)
            else:
                children.append(c)
        self.flat_node[node] = Node(node.kind, children)
    elif isinstance(node, Node):
        children = []
        for a in node.args:
            children.append(self.flat_node[a])
        self.flat_node[node] = Node(node.kind, children)
def visit(self, node, is_leaving):
    if (not is_leaving):
        self.flat_node[node] = node
        return
    if (isinstance(node, Node) and (node.kind == NT.STMTLIST)):
        children = []
        for a in node.args:
            c = self.flat_node[a]
            if (c.kind == NT.STMTLIST):
                children.extend(c.args)
            else:
                children.append(c)
        self.flat_node[node] = Node(node.kind, children)
    elif isinstance(node, Node):
        children = []
        for a in node.args:
            children.append(self.flat_node[a])
        self.flat_node[node] = Node(node.kind, children)