void (final Set<? extends PsiFile> searchIn, final Set<? extends PsiFile> searchFor, Processor<? super List<PsiFile>> processor) { if (myTransitiveBorder == 0) return; Set<PsiFile> initialSearchFor = new HashSet<>(searchFor); for (DependenciesBuilder builder : myBuilders) { for (PsiFile from : searchIn) { for (PsiFile to : initialSearchFor) { final List<List<PsiFile>> paths = builder.findPaths(from, to); paths.sort(Comparator.comparingInt(List::size)); for (List<PsiFile> path : paths) { if (!path.isEmpty()){ path.add(0, from); path.add(to); if (!processor.process(path)) return; } } } } } }