def extract_submodules(module, module_tree):
    """
    Returns the list of submodules for a given module in a module hierarchy.
    Example:
        module_tree = [test,
                       test.one,
                       test.one.two,
                       test.one.three,
                       test.four]

        extract_submodules('test.one', module_tree)
        >>> [two, three]

        extract_submodules('test', module_tree)
        >>> [one, four]
    """
    submodules = []
    module_prefix = module.__name__ + "."

    for submod in module_tree:
        submod_name = submod.__name__
        prefix_pred = submod_name.startswith(module_prefix)
        if prefix_pred and not "." in submod_name.split(module_prefix, 1)[1]:
            submodules.append(submod)

    return submodules