public static List<VirtualFile> findPomFiles(VirtualFile[] roots,
                                               boolean lookForNested,
                                               @Nullable ProgressIndicator indicator) throws MavenProcessCanceledException {
    List<Pair<VirtualFile, VirtualFile>> result = new ArrayList<>();
    // TODO locate pom files using maven embedder?
    for (VirtualFile f : roots) {
      VfsUtilCore.visitChildrenRecursively(f, new VirtualFileVisitor<Void>() {
        @Override
        public boolean visitFile(@NotNull VirtualFile f) {
          try {
            if (null != indicator) {
              indicator.checkCanceled();
              indicator.setText2(f.getPresentableUrl());
            }

            if (f.isDirectory()) {
              if (lookForNested) {
                f.refresh(false, false);
              }
              else {
                return false;
              }
            }
            else {
              if (MavenUtil.isPomFile(f)) {
                result.add(Pair.create(f.getParent(), f));
              }
            }
          }
          catch (InvalidVirtualFileAccessException e) {
            // we are accessing VFS without read action here so such exception may occasionally occur
            MavenLog.LOG.info(e);
          }
          return true;
        }
      }, MavenProcessCanceledException.class);
    }
    Map<VirtualFile, List<VirtualFile>> pomFilesByParent = result.stream()
      .collect(groupingBy(p -> p.getFirst(), mapping(p -> p.getSecond(), toList())));
    return pomFilesByParent.entrySet().stream()
      .flatMap(pomsByParent -> getOriginalPoms(pomsByParent.getValue()).stream())
      .collect(toList());
  }
public static List<VirtualFile> findPomFiles(VirtualFile[] roots,
                                               boolean lookForNested,
                                               @Nullable ProgressIndicator indicator)