private function searchParentOfInParentedMode(ModelInterface $model)
    {
        if ($this->defaultProviderName !== $model->getProviderName()) {
            throw new DcGeneralInvalidArgumentException(
                'Model originates from ' . $model->getProviderName() .
                ' but is expected to be from ' . $this->defaultProviderName .
                ' can not determine parent.'
            );
        }

        $condition = $this->relationships->getChildCondition($this->parentProviderName, $this->defaultProviderName);
        // This is pretty expensive, we fetch all models from the parent provider here.
        // This can be much faster by using the inverse condition if present.
        foreach ($this->parentProvider->fetchAll($this->parentProvider->getEmptyConfig()) as $candidate) {
            if ($condition->matches($candidate, $model)) {
                return $candidate;
            }
        }

        return null;
    }