RecursiveFilePathSet (@Nullable RecursiveFilePathSet dirs) { RecursiveFilePathSet result = newRecursiveFilePathSet(); if (dirs == null) return result; List<FilePath> paths = ContainerUtil.sorted(dirs.filePaths(), Comparator.comparingInt(it -> it.getPath().length())); for (FilePath path : paths) { if (result.hasAncestor(path)) continue; result.add(path); } return result; }