def process(tree, processes=['sub', 'toc', 'xref'], **kwargs):
    """ Process the given tree. """
    for process in processes:
        try:
            process_module = getattr(__import__('processes', globals(),
                locals(), [str(process)], -1), process)
        except AttributeError:
            process_module = __import__(process, globals(), locals(), [], -1)
        getattr(process_module, process)(tree, **kwargs)
