public static @NotNull List<File> findFilesByMask(@NotNull Pattern pattern, @NotNull File dir) {
    List<File> found = new ArrayList<>();
    File[] files = dir.listFiles();
    if (files != null) {
      for (File file : files) {
        if (file.isDirectory()) {
          found.addAll(findFilesByMask(pattern, file));
        }
        else if (pattern.matcher(file.getName()).matches()) {
          found.add(file);
        }
      }
    }
    return found;
  }
public static @NotNull List<File> findFilesByMask(@NotNull Pattern pattern, @NotNull File dir)