private static void collectAndShowDuplicates(final Project project) {
    final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
    if (indicator != null && !indicator.isCanceled()) {
      indicator.setText("Collecting project images...");
      indicator.setIndeterminate(false);
      final List<VirtualFile> images = new ArrayList<>();
      for (String ext : IMAGE_EXTENSIONS) {
        images.addAll(ReadAction.compute(() -> FilenameIndex.getAllFilesByExt(project, ext)));
      }

      final Map<Long, Set<VirtualFile>> duplicates = new HashMap<>();
      final Map<Long, VirtualFile> all = new HashMap<>();
      for (int i = 0; i < images.size(); i++) {
        indicator.setFraction((double)(i + 1) / (double)images.size());
        final VirtualFile file = images.get(i);
        ReadAction.run(() -> {
          if (!(file.getFileSystem() instanceof LocalFileSystem)) return;
          final long length = file.getLength();
          if (all.containsKey(length)) {
            if (!duplicates.containsKey(length)) {
              final HashSet<VirtualFile> files = new HashSet<>();
              files.add(all.get(length));
              duplicates.put(length, files);
            }
            duplicates.get(length).add(file);
          }
          else {
            all.put(length, file);
          }
        });
        indicator.checkCanceled();
      }
      showResults(project, images, duplicates);
    }
  }
private static void collectAndShowDuplicates(final Project project)