code: def to_dict(self):
          
          entity_dict = {}
  
          for field, val in six.iteritems(self._fields):
              if field.multiple:
                  if val:
                      val = [_dictify(field, x) for x in val]
                  else:
                      val = []
              else:
                  val = _dictify(field, val)
  
              # Only add non-None objects or non-empty lists
              if val is not None and val != []:
                  entity_dict[field.key_name] = val
  
          self._finalize_dict(entity_dict)
  
          return entity_dict
docs: Convert to a ``dict``
  
          Subclasses can override this function.
  
          Returns:
              Python dict with keys set from this Entity.