def group_for_key(key):
 if (not isinstance(key, entity_pb.Reference)):
  key = entity_pb.Reference(key)
 first_element = key.path().element(0)
 key_copy = entity_pb.Reference()
 key_copy.CopyFrom(key)
 key_copy.path().clear_element()
 element = key_copy.path().add_element()
 element.MergeFrom(first_element)
 return key_copy

def group_for_key ( key ) : if ( not isinstance ( key , entity_pb . Reference ) ) : key = entity_pb . Reference ( key ) first_element = key . path ( ) . element ( 0 ) key_copy = entity_pb . Reference ( ) key_copy . CopyFrom ( key ) key_copy . path ( ) . clear_element ( ) element = key_copy . path ( ) . add_element ( ) element . MergeFrom ( first_element ) return key_copy
extract the root path for a given key .