'Collect entity key to be reserved if it has a numeric id in its path.
Keys to reserve are stored in self.keys_to_reserve.
They are not tracked if self.reserve_keys is None.
Args:
entity: An entity with a key.'

def __reserve_entity_key(self, entity):

    if (not self.reserve_keys):
        return
    if isinstance(entity, datastore.Entity):
        if (not entity.key()):
            return
    elif (not entity.has_key()):
        return
    key = entity.key()
    if (not key.has_id_or_name()):
        return
    for id_or_name in key.to_path()[1::2]:
        if isinstance(id_or_name, (int, long)):
            self.keys_to_reserve.append(key)
            return
