protected function arrayContainsObject(array $array, $object, $identifier)
    {
        if (in_array($object, $array, true) === true) {
            return true;
        }

        foreach ($array as $value) {
            if ($value instanceof $object && $this->persistenceSession->getIdentifierByObject($value) === $identifier) {
                return true;
            }
        }

        return false;
    }