def METHOD_NAME(pkg_name):
    # type: (str) -> Dict[str, ModuleType]
    in_installed_path = functools.partial(
        path_contains,
        os.path.join(
            sublime.installed_packages_path(),
            pkg_name + '.sublime-package'
        )
    )
    in_package_path = functools.partial(
        path_contains,
        os.path.join(sublime.packages_path(), pkg_name)
    )
    def module_in_package(module):
        # Other (extracted) ST plugins using python 3.8 have this set to
        # `None` surprisingly.
        file = getattr(module, '__file__', None) or ''
        paths = getattr(module, '__path__', ())
        return (
            in_installed_path(file) or any(map(in_installed_path, paths)) or
            in_package_path(file) or any(map(in_package_path, paths))
        )
    return {
        name: module
        for name, module in sys.modules.items()
        if module_in_package(module)
    }