protected function getCriteria($entity, Constraint $constraint, ObjectManager $em)
    {
        /** @var UniqueEntity $constraint */
        /** @var \Doctrine\ORM\Mapping\ClassMetadata $class */
        $class = $em->getClassMetadata(ClassUtils::getClass($entity));
        $fields = (array) $constraint->fields;
        $criteria = [];

        foreach ($fields as $fieldName) {
            $criteria = $this->findFieldCriteria($criteria, $constraint, $em, $class, $entity, $fieldName);

            if (null === $criteria) {
                break;
            }
        }

        return $criteria;
    }