docs: def encode(val):
      """
      Encode a string assuming the encoding is UTF-8.
  
      :param: a unicode or bytes object
      :returns: bytes
      """
      if isinstance(val, (list, tuple)):  # encode a list or tuple of strings
          return [encode(v) for v in val]
      elif isinstance(val, str):
          return val.encode('utf-8')
      else:
          # assume it was an already encoded object
          return val