def to_dict(model_instance, dictionary=None):
  """Convert model to dictionary.

  Args:
    model_instance: Model instance for which to make dictionary.
    dictionary: dict instance or compatible to receive model values.
      The dictionary is not cleared of original values.  Similar to using
      dictionary.update.  If dictionary is None, a new dictionary instance is
      created and returned.

    Returns:
      New dictionary appropriate populated with model instances values
      if entity is None, else entity.
  """
  if dictionary is None:
    dictionary = {}

  model_instance._to_entity(dictionary)
  return dictionary