Set<PsiFile> (PsiPackage firstPack, PsiPackage middlePack, PsiPackage lastPack) { Set<PsiFile> result = new HashSet<>(); final Map<PsiPackage, Set<PsiFile>> forwardMap = myFilesInDependentPackages.get(firstPack); if (forwardMap != null && forwardMap.get(middlePack) != null){ result.addAll(forwardMap.get(middlePack)); } final Map<PsiPackage, Set<PsiFile>> backwardMap = myBackwardFilesInDependentPackages.get(lastPack); if (backwardMap != null && backwardMap.get(middlePack) != null){ result.addAll(backwardMap.get(middlePack)); } return result; }