code: def to_dict(self):
          
          if not hasattr(self, '_fields'):
              return self.__dict__
          result = dict()
          for field_name, field in self._fields.items():
              if isinstance(field, xmlmap.NodeField):
                  obj = getattr(self, field_name)
                  if obj is None:
                      result[field_name] = None
                  elif not hasattr(obj, 'to_dict'):
                      result[field_name] = obj.__dict__
                  else:
                      result[field_name] = obj.to_dict()
              elif isinstance(field, xmlmap.NodeListField):
                  objs = getattr(self, field_name)
                  result[field_name] = list()
                  for obj in objs:
                      if not hasattr(obj, 'to_dict'):
                          result[field_name].append(obj.__dict__)
                      else:
                          result[field_name].append(obj.to_dict())
              else:
                  result[field_name] = getattr(self, field_name)
          return result
docs: Recusively exports object values to a dict
  
          :return: `dict`of values