code: public static File findFile(File rootDir, FilenameFilter filter) {
          File[] files = rootDir.listFiles(filter);
          Arrays.sort(files);
          if (files.length > 0) {
              return files[0];
          }
  
          files = rootDir.listFiles(directoryFilter);
          Arrays.sort(files);
          for (File subDir : files) {
              File found = findFile(subDir, filter);
              if (found != null) {
                  return found;
              }
          }
          return null;
      }
docs: Finds a file matching the given file name filter in the given root directory or any
  subdirectory. The files and directories are scanned in alphabetical order, so the result is
  deterministic.
  <p>
  The method returns the first matching result, if any, and ignores all other matches.
  
  @param rootDir
  root directory
  @param filter
  file name filter
  @return matching file, or null