code: def save_pkl(filename=None, times=None):
      
      if times is None:
          if not f.root.stopped:
              times = collapse.collapse_times()
          else:
              times = f.root.times
      else:
          if isinstance(times, (list, tuple)):
              for t in times:
                  if not isinstance(t, Times):
                      raise TypeError("Expected single Times instance or list/tuple of Times instances for param 'times'.")
          elif not isinstance(times, Times):
              raise TypeError("Expected single Times instance or list/tuple of Times instances for param 'times'.")
      if filename is not None:
          with open(str(filename), 'wb') as file:
              pickle.dump(times, file)
      else:
          return pickle.dumps(times)
docs: Serialize and / or save a Times data object using pickle (cPickle).
  
      Args:
          filename (None, optional): Filename to dump to. If not provided,
              returns serialized object.
          times (None, optional): object to dump.  If non provided, uses
              current root.
  
      Returns:
          pkl: Pickled Times data object, only if no filename provided.
  
      Raises:
          TypeError: If 'times' is not a Times object or a list of tuple of
              them.