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