How to gather output files from subdirectories

Hello,
I have a tool that downloads a database with image files saved in subdirectories within the output folder. I’m writing a CWL for this tool to gather the files from these subdirectories, but it fails because inputs.outDir.listing is empty. It seems that loadContents doesn’t work for arrays.
I appreciate your help!

class: CommandLineTool
cwlVersion: v1.2
inputs:
  name:
    inputBinding:
      prefix: --name
    type: string
  outDir:
    inputBinding:
      prefix: --outDir
    type: Directory

  glob_pattern:
    type: string
    default: "."

outputs:
  outDir:
    outputBinding:
      glob: $(inputs.outDir.basename) #"$(inputs.inputDir)/**/*.tif"
    type: Directory

  output_files:
    type: File[]
    outputBinding:
      glob: $(inputs.outDir.basename)/* 
      loadContents: true
      outputEval: |
        ${
          var tifFiles = [];
          
          function findTifFiles(dir) {
            for (var item of dir.listing) {
              if (item.class == 'Directory') {
                findTifFiles(item); // Recursively search subdirectories
              } else if (item.class == 'File' && item.basename.endsWith('.tif')) {
                tifFiles.push({ "class": "File", "path": item.path });
              }
            }
          }
          
          findTifFiles(inputs.outDir); // Start the recursive search in outDir
          return tifFiles;
        }      
baseCommand: ["python3", "-m", "polus.plugins.utils.bbbc_download"]
requirements:
  DockerRequirement:
    dockerPull: polusai/bbbc-download-plugin:0.1.0-dev1
  InitialWorkDirRequirement:
    listing:
    - entry: $(inputs.outDir)
      writable: true
  InlineJavascriptRequirement: {}
  NetworkAccess:
    networkAccess: true