def METHOD_NAME(module, tree=None, seen=None, root=None, nobjects=0):
    """
    Recursively access every accessible element of the given module, building
    up a complete tree structure where the keys are the parts of the module
    name, and the eventual leaves are public functions and classes defined in
    that particular module (so ignoring any names that leak in from other
    imports).  For example,
        >>> import qutip
        >>> python_object_tree(qutip)
        {
            "mesolve" : {
                "mesolve": <function qutip.mesolve.mesolve(...)>,
            },
            ...
        }
    """
    tree = tree if tree is not None else {}
    seen = seen if seen is not None else set()
    root = root if root is not None else (module.__name__ + ".")
    if module in seen:
        return tree, nobjects
    seen.add(module)
    our_tree = _our_tree(module, tree)
    for _, obj in inspect.getmembers(module):
        if inspect.isclass(obj) or inspect.isroutine(obj):
            object_module = inspect.getmodule(obj)
            if object_module is module:
                if not obj.__name__.startswith("_"):
                    our_tree[obj.__name__] = obj
                    nobjects += 1
                continue
            # Fall through, so we recursively comb through modules.
            obj = object_module
        if inspect.ismodule(obj) and not _ignore(obj, root):
            if obj.__name__.startswith(root):
                _, nobjects =\
                    METHOD_NAME(obj, tree, seen, root, nobjects)
    # Also do our parent package, if we have one.  In theory it's possible to
    # get into a situation with packages and overzealous use of "del" in init
    # scripts where a submodule may be accessible but its parent isn't.
    parent = ".".join(module.__name__.split(".")[:-1])
    if parent.startswith(root):
        _, nobjects =\
            METHOD_NAME(sys.modules[parent], tree, seen, root, nobjects)
    return tree, nobjects