private static function mergeTwoValues($originalValue, $newValue, $parentKeys)
    {
        $originalIsArray = is_array($originalValue);
        $newIsArray = is_array($newValue);

        if ($originalIsArray && $newIsArray) {
            return self::mergeArraysRecursively($originalValue, $newValue, $parentKeys);
        }
        elseif (!$originalIsArray && !$newIsArray) {
            // Value from the second array overrides the first:
            return $newValue;
        }
        else {
            throw new InconsistentKeyTypes($originalValue, $newValue, implode('.', $parentKeys));
        }
    }