Recursive print worker - recurses the AST and prints each node.

def _recurse(node, *args, **kwargs):
    """Recursive print worker - recurses the AST and prints each node."""
    node_name = node.__class__.__name__
    try:
        info_for_node = _NODE_INFO_TABLE[node_name]
    except KeyError:
        return

    action = kwargs[info_for_node.handler]
    depth = kwargs["depth"]

    # Invoke action if available
    if action is not None:
        action(node_name, node, depth)

    # Recurse
    recurse_kwargs = kwargs
    kwargs["depth"] = depth + 1

    for single in info_for_node.single:
        _recurse(getattr(node, single),
                 *args,
                 **recurse_kwargs)

    for multi in info_for_node.multi:
        for statement in getattr(node, multi):
            _recurse(statement,
                     *args,
                     **recurse_kwargs)