private function isLastEnabledEntity($result, $entity): bool
    {
        return !$result || 0 === count($result)
        || (1 === count($result) && $entity === ($result instanceof \Iterator ? $result->current() : current($result)));
    }