Collection<VcsRoot> (@NotNull Collection<? extends VirtualFile> dirsToScan, @NotNull Map<VirtualFile, Boolean> scannedDirs, @NotNull Collection<VcsRoot> detectedRoots) { Set<VirtualFile> skipDirs = new HashSet<>(); for (VcsRoot root : detectedRoots) { skipDirs.add(root.getPath()); } // ignore mappings in ~/ and above ContainerUtil.addIfNotNull(skipDirs, VfsUtil.getUserHomeDir()); Set<VcsRoot> result = new HashSet<>(); for (VirtualFile dir : dirsToScan) { scanForRootsAboveDir(dir, scannedDirs, skipDirs, result); } return result; }