private function updateQueryTranslations(QueryTypeInterface $queryType, PersistenceQuery $persistenceQuery, APIQueryUpdateStruct $queryUpdateStruct): PersistenceQuery
    {
        if ($queryUpdateStruct->locale === $persistenceQuery->mainLocale) {
            $persistenceQuery = $this->collectionHandler->updateQueryTranslation(
                $persistenceQuery,
                $queryUpdateStruct->locale,
                QueryTranslationUpdateStruct::fromArray(
                    [
                        'parameters' => iterator_to_array(
                            $this->parameterMapper->serializeValues(
                                $queryType,
                                $queryUpdateStruct->getParameterValues(),
                                $persistenceQuery->parameters[$persistenceQuery->mainLocale]
                            )
                        ),
                    ]
                )
            );
        }

        $untranslatableParams = iterator_to_array(
            $this->parameterMapper->extractUntranslatableParameters(
                $queryType,
                $persistenceQuery->parameters[$persistenceQuery->mainLocale]
            )
        );

        $localesToUpdate = [$queryUpdateStruct->locale];
        if ($persistenceQuery->mainLocale === $queryUpdateStruct->locale) {
            $localesToUpdate = $persistenceQuery->availableLocales;

            // Remove the main locale from the array, since we already updated that one
            $mainLocaleOffset = array_search($persistenceQuery->mainLocale, $persistenceQuery->availableLocales, true);
            if (is_int($mainLocaleOffset)) {
                array_splice($localesToUpdate, $mainLocaleOffset, 1);
            }
        }

        foreach ($localesToUpdate as $locale) {
            $params = $persistenceQuery->parameters[$locale];

            if ($locale === $queryUpdateStruct->locale) {
                $params = iterator_to_array(
                    $this->parameterMapper->serializeValues(
                        $queryType,
                        $queryUpdateStruct->getParameterValues(),
                        $params
                    )
                );
            }

            $persistenceQuery = $this->collectionHandler->updateQueryTranslation(
                $persistenceQuery,
                $locale,
                QueryTranslationUpdateStruct::fromArray(
                    [
                        'parameters' => $untranslatableParams + $params,
                    ]
                )
            );
        }

        return $persistenceQuery;
    }