def _normalize_entity(value):
 if ((ndb is not None) and isinstance(value, ndb.Model)):
  return None
 if getattr(value, '_populate_internal_entity', None):
  return value._populate_internal_entity()
 return value

def _normalize_entity ( value ) : if ( ( ndb is not None ) and isinstance ( value , ndb . Model ) ) : return None if getattr ( value , '_populate_internal_entity' , None ) : return value . _populate_internal_entity ( ) return value
return an entity from an entity or model instance .