protected function applyRecursive($query, array $targetParts, $value, $isFirst = false)
    {
        if (count($targetParts) < 2) {

            if ($this->translated) {
                return $this->applyTranslatedValue($query, head($targetParts), $value, $isFirst);
            }

            return $this->applyValue($query, head($targetParts), $value, null, $isFirst);
        }

        $relation = array_shift($targetParts);

        $whereHasMethod = ! $isFirst && $this->combineOr ? 'orWhereHas' : 'whereHas';

        return $query->{$whereHasMethod}(
            $relation,
            function ($query) use ($targetParts, $value) {
                return $this->applyRecursive($query, $targetParts, $value, true);
            }
        );
    }