'Returns this entity\'s parent, as a Key. If this entity has no parent,
returns None.'

def parent(self):

    if (self.__reference.path().element_size() > 1):
        parent = Key()
        parent.__reference.CopyFrom(self.__reference)
        del parent.__reference.path().element_list()[(-1)]
        return parent
    else:
        return None
