private static function arrayMergeRecursiveDistinct(array $merged, array $other): array
    {
        foreach ($other as $key => $value) {
            if (is_array($value) && is_array($merged[$key] ?? [])) {
                $merged[$key] = self::arrayMergeRecursiveDistinct($merged[$key] ?? [], $value);
            } elseif (is_int($key)) {
                // Avoid arrays being overridden.
                $merged = array_unique(
                    array_merge($merged, [$value])
                );
            } else {
                $merged[$key] = $value;
            }
        }

        return $merged;
    }