List<List<PsiFile>> (PsiFile from, PsiFile to, Set<? super PsiFile> processed) { final List<List<PsiFile>> result = new ArrayList<>(); final Set<PsiFile> reachable = getDirectDependencies().get(from); if (reachable != null) { if (reachable.contains(to)) { result.add(new ArrayList<>()); return result; } if (processed.add(from)) { for (PsiFile file : reachable) { if (!getScope().contains(file)) { //exclude paths through scope final List<List<PsiFile>> paths = findPaths(file, to, processed); for (List<PsiFile> path : paths) { path.add(0, file); } result.addAll(paths); } } } } return result; }