docs: def collapse(l, raw):
      """
      LiPD Version 1.3
      Main function to initiate time series to LiPD conversion
  
      Each object has a:
      "paleoNumber" or "chronNumber"
      "tableNumber"
      "modelNumber"
      "time_id"
      "mode" - chronData or paleoData
      "tableType" - "meas" "ens" "summ"
  
      :param list l: Time series
      :return dict _master: LiPD data, sorted by dataset name
      """
      logger_ts.info("enter collapse")
      # LiPD data (in progress), sorted dataset name
      _master = {}
      _dsn = ""
  
      try:
          # Determine if we're collapsing a paleo or chron time series
          _pc = l[0]["mode"]
  
          # Loop the time series
          for entry in l:
              # Get notable keys
              dsn = entry['dataSetName']
              _dsn = dsn
              _current = entry
  
              # Since root items are the same in each column of the same dataset, we only need these steps the first time.
              if dsn not in _master:
                  logger_ts.info("collapsing: {}".format(dsn))
                  print("collapsing: {}".format(dsn))
                  _master, _current = _collapse_root(_master, _current, dsn, _pc)
                  try:
                      _master[dsn]["paleoData"] = raw[dsn]["paleoData"]
                      if "chronData" in raw[dsn]:
                          _master[dsn]["chronData"] = raw[dsn]["chronData"]
                  except KeyError as e:
                      print("collapse: Could not collapse an object the dataset: {}, {}".format(dsn, e))
  
              # Collapse pc, calibration, and interpretation
              _master = _collapse_pc(_master, _current, dsn, _pc)
  
          # The result combined into a single dataset. Remove the extra layer on the data.
          if len(_master) == 1:
              _master = _master[_dsn]
              print("Created LiPD data: 1 dataset")
          else:
              print("Created LiPD data: {} datasets".format(len(_master)))
  
      except Exception as e:
          print("Error: Unable to collapse time series, {}".format(e))
          logger_ts.error("collapse: Exception: {}".format(e))
  
      logger_ts.info("exit collapse")
      return _master