'Returns this entity\'s id, or None if it doesn\'t have one.'

def id(self):

    elems = self.__reference.path().element_list()
    if (elems and elems[(-1)].has_id() and elems[(-1)].id()):
        return elems[(-1)].id()
    else:
        return None
