def get_changed_entities(new_entity_list, old_entity_list):
  """Returns subset of changed entites.

  Compares entites from |new_entity_list| with entities from |old_entity_list|
  with same key, returns all changed or added entities.
  """
  old_by_key = {x.key: x for x in old_entity_list}
  new_or_changed = []
  for new_entity in new_entity_list:
    old_entity = old_by_key.get(new_entity.key)
    if not old_entity or old_entity.to_dict() != new_entity.to_dict():
      new_or_changed.append(new_entity)
  return new_or_changed