Set<String> (@NotNull PsiJavaModule currentModule, @NotNull PsiJavaModule dependencyModule) { Set<String> directDependencies = StreamEx .of(currentModule.getRequires().iterator()) .map(PsiRequiresStatement::getModuleName) .nonNull() .toSet(); List<PsiJavaModule> transitiveModules = StreamEx .of(dependencyModule.getRequires().iterator()) .filter(statement -> statement.hasModifierProperty(PsiModifier.TRANSITIVE)) .filter(requiresStatement -> !directDependencies.contains(requiresStatement.getModuleName())) .map(PsiRequiresStatement::resolve) .nonNull() .toList(); return StreamEx.of(transitiveModules) .filter(transitiveModule -> isReexported(currentModule, transitiveModule)) .map(transitiveModule -> transitiveModule.getName()) .toSet(); }