def get_toplevel_functions(xml_tree, name=None):
    path = "./compounddef/sectiondef[@kind='%s']/memberdef[@kind='function']"
    if name:
        path = ("%s/[name='%s']" % (path, name))
    all_nodes = []
    for section_kind in ['func', 'user-defined']:
        nodes = xml_tree.findall((path % section_kind))
        all_nodes.extend(map((lambda n: n), nodes))
    return all_nodes
def get_toplevel_functions(xml_tree, name=None):
    path = "./compounddef/sectiondef[@kind='%s']/memberdef[@kind='function']"
    if name:
        path = ("%s/[name='%s']" % (path, name))
    all_nodes = []
    for section_kind in ['func', 'user-defined']:
        nodes = xml_tree.findall((path % section_kind))
        all_nodes.extend(map((lambda n: n), nodes))
    return all_nodes