docs: def serialize_object(self, attr, **kwargs):
          """Serialize a generic object.
          This will be handled as a dictionary. If object passed in is not
          a basic type (str, int, float, dict, list) it will simply be
          cast to str.
  
          :param dict attr: Object to be serialized.
          :rtype: dict or str
          """
          if attr is None:
              return None
          if isinstance(attr, ET.Element):
              return attr
          obj_type = type(attr)
          if obj_type in self.basic_types:
              return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs)
          if obj_type is _long_type:
              return self.serialize_long(attr)
  
          # If it's a model or I know this dependency, serialize as a Model
          elif obj_type in self.dependencies.values() or isinstance(obj_type, Model):
              return self._serialize(attr)
  
          if obj_type == dict:
              serialized = {}
              for key, value in attr.items():
                  try:
                      serialized[self.serialize_unicode(key)] = self.serialize_object(
                          value, **kwargs)
                  except ValueError:
                      serialized[self.serialize_unicode(key)] = None
              return serialized
  
          if obj_type == list:
              serialized = []
              for obj in attr:
                  try:
                      serialized.append(self.serialize_object(
                          obj, **kwargs))
                  except ValueError:
                      pass
              return serialized
          return str(attr)