Set<Module> (@NotNull Module fromModule, Module @NotNull [] allModules) { Set<Module> result = new HashSet<>(); for (Module module : allModules) { ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module); OrderEntry[] orderEntries = moduleRootManager.getOrderEntries(); for (OrderEntry orderEntry : orderEntries) { if (orderEntry instanceof ModuleOrderEntry && ((ExportableOrderEntry)orderEntry).isExported() && fromModule == ((ModuleOrderEntry)orderEntry).getModule()) { result.addAll(getDirectBackwardDependencies(module, allModules)); } } } return result; }