public static VirtualFile @NotNull [] filterAllowedRoots(@NotNull Project project,
                                                           @NotNull List<VirtualFile> mappings,
                                                           @NotNull AbstractVcs vcs) {
    if (vcs.allowsNestedRoots()) {
      return VfsUtilCore.toVirtualFileArray(mappings);
    }

    List<VirtualFile> result = new ArrayList<>(mappings);
    result.sort(FilePathComparator.getInstance());

    ApplicationManager.getApplication().runReadAction(() -> {
      final FileIndexFacade facade = FileIndexFacade.getInstance(project);
      int i = 1;
      while (i < result.size()) {
        final VirtualFile previous = result.get(i - 1);
        final VirtualFile current = result.get(i);
        if (facade.isValidAncestor(previous, current)) {
          result.remove(i);
        }
        else {
          i++;
        }
      }
    });
    return VfsUtilCore.toVirtualFileArray(result);
  }
public static VirtualFile @NotNull [] filterAllowedRoots(@NotNull Project project,
                                                           @NotNull List<VirtualFile> mappings,
                                                           @NotNull AbstractVcs vcs)