def _find_transitive_dependencies(self, name, seen=None):
        """Transitively find all dependencies of a module."""
        if seen is None:
            seen = set((name,))
        moddata = self.modules.get(name)
        if moddata is not None:
            deps = set()
            imports = moddata.get("imports")
            if imports is not None:
                deps.update(imports)
            if "dir" in moddata:
                deps.add(name + ".__init__")
            if "." in name:
                deps.add(name.rsplit(".", 1)[0])
            seen.add(name)
            for dep in deps:
                if dep not in seen:
                    self._find_transitive_dependencies(dep, seen)
        return seen
Transitively find all dependencies of a module.
tools/module_bundler.py