import itertools


def _preorder_walk(node, _app=None):
    """Walk the tree in preorder"""
    return itertools.chain(
        [node],
        *[_preorder_walk(child) for child in node.children]
    )