code: def stage(x, staging):
      
      linknames = []
  
      # Objects that don't represent a file shouldn't be staged
      non_file_objects = (
          track.ViewTrack,
          track.CompositeTrack,
          track.AggregateTrack,
          track.SuperTrack,
          genome.Genome,
      )
      if isinstance(x, non_file_objects):
          return linknames
  
      # If it's an object representing a file, then render it.
      #
      # Track objects don't represent files, but their documentation does
      linknames.append(x.render(staging))
  
      if hasattr(x, 'source') and hasattr(x, 'filename'):
          def _stg(x, ext=''):
              # A remote track hosted elsewhere does not need staging. This is
              # defined by a track with a url, but no source or filename.
              if (
                  x.source is None
                  and x.filename is None
                  and getattr(x, 'url', None) is not None
              ):
                  return
  
              linknames.append(
                  local_link(x.source + ext, x.filename + ext, staging)
              )
  
          _stg(x)
  
          if isinstance(x, track.Track):
              if x.tracktype == 'bam':
                  _stg(x, ext='.bai')
              if x.tracktype == 'vcfTabix':
                  _stg(x, ext='.tbi')
  
          if isinstance(x, track.CompositeTrack):
              if x._html:
                  _stg(x._html)
  
      return linknames
docs: Stage an object to the `staging` directory.
  
      If the object is a Track and is one of the types that needs an index file
      (bam, vcfTabix), then the index file will be staged as well.
  
      Returns a list of the linknames created.