public function searchParentOfIn(ModelInterface $model, CollectionInterface $models)
    {
        foreach ($models as $candidate) {
            /** @var ModelInterface $candidate */
            foreach ($this->relationships->getChildConditions($candidate->getProviderName()) as $condition) {
                if ($condition->matches($candidate, $model)) {
                    return $candidate;
                }

                $provider = $this->environment->getDataProvider($condition->getDestinationName());
                $config   = $provider->getEmptyConfig()->setFilter($condition->getFilter($candidate));
                $result   = $this->searchParentOfIn($model, $provider->fetchAll($config));
                if (null !== $result) {
                    return $result;
                }
            }
        }

        return null;
    }