def METHOD_NAME(self, uid: int) -> Optional[PolyPointer[Entity]]:
    if self.meta.table_ptr == 0:
        return None
    # -1 is used as a null-like value
    if uid == -1:
        return None
    addr = self._get_addr(uid)
    if addr == 0:
        return None
    entity: Optional[Entity] = self.mem_ctx.type_at_addr(Entity, addr)
    if entity is None:
        return None
    if entity.uid != uid:
        logger.warning(
            "Entity lookup failed with ID mismatch. Expected %d, got %d",
            uid,
            entity.uid,
        )
        return None
    return PolyPointer[Entity](addr, entity, self.mem_ctx)