code: public static FileStatus getAnyNonHiddenFile(FileSystem fs, Path path)
        throws IOException {
      HiddenFilter hiddenFilter = new HiddenFilter();
  
      FileStatus root = fs.getFileStatus(path);
      if (!root.isDirectory()) {
        return hiddenFilter.accept(path) ? root : null;
      }
  
      // DFS to get the first data file
      Stack<FileStatus> folders = new Stack<>();
      folders.push(root);
      while (!folders.empty()) {
        FileStatus curFolder = folders.pop();
        try {
          for (FileStatus status : fs.listStatus(curFolder.getPath(), hiddenFilter)) {
            if (status.isDirectory()) {
              folders.push(status);
            } else {
              return status;
            }
          }
        } catch (FileNotFoundException exc) {
          // continue
        }
      }
  
      return null;
    }
docs: Get any data file, which is not hidden or a directory, from the given path