def METHOD_NAME(app, fromdocname, classes, container, caption, module_index, label_prefix):
    toc = nodes.bullet_list()
    toc += nodes.caption(caption, '', *[nodes.Text(caption)])
    if module_index is not None:
        entries = defaultdict(list)
        #print("test", classes, fromdocname, caption)
        prefix = ".".join(classes[0][0].split(".")[:module_index]) + "."
        for e in classes:
            module = e[0].split(".")[module_index]
            entries[module].append(e)
        #print("t", fromdocname)
        for module, class_list in entries.items():
            #print("t2", "src." + prefix + module)
            ref = nodes.reference('', '')
            ref['refuri'] = app.builder.get_relative_uri(fromdocname, prefix + module)
            ref.append(nodes.Text((label_prefix + module) if label_prefix != "" else module.capitalize()))
            module_item = nodes.list_item('', addnodes.compact_paragraph('', '', ref), classes=["toctree-l1"])
            if fromdocname.startswith(prefix + module):
                module_item["classes"].append('current')
            toc += module_item
            subtree = nodes.bullet_list()
            module_item += subtree
            generate_classlist(app, fromdocname, subtree, class_list, "")
    else:
        generate_classlist(app, fromdocname, toc, classes, label_prefix, level=1)
    container += toc