code: def to_dict(self, val=UNSET):
          
          if val is UNSET:
              val = self
  
          if isinstance(val, dict2) or isinstance(val, dict):
              res = dict()
              for k, v in val.items():
                  res[k] = self.to_dict(v)
              return res
          elif isinstance(val, list):
              res = []
              for item in val:
                  res.append(self.to_dict(item))
              return res
          else:
              return val
docs: Creates dict object from dict2 object
  
          Args:
              val (:obj:`dict2`): Value to create from
  
          Returns:
              Equivalent dict object.