def node_to_dict(node):
    """ Convert a node to a dictionary representation. We skip the
    children, turning them instead into a list of labels instead. """
    if not hasattr(node, 'child_labels'):
        node.child_labels = [c.label_id() for c in node.children]

    node_dict = {}
    for k, v in node.__dict__.items():
        if k not in ('children', 'source_xml'):
            node_dict[k] = v
    return node_dict