def Expand(target_entity, property_, expanded_entity):
  """Merges one entity into another as if it were expanded on property_.

  Args:
    target_entity: api.Model
    property_: api.Property, The property for which the expand should be
        generated.
    expanded_entity: api.Model

  Returns:
    A copy of the target_entity object with the expanded contents of
    expanded_entity.
  """
  # pylint: disable=protected-access
  expand_dict = {
      '{}_{}'.format(property_.name, key): value
      for key, value in expanded_entity._obj_dict.iteritems()}
  entity_copy = target_entity.__class__()
  entity_copy._obj_dict.update(target_entity._obj_dict)
  entity_copy._obj_dict.update(expand_dict)
  return entity_copy
  # pylint: enable=protected-access