public static function mergeUnique(array $first, array $second, $preserveNumericKeys = false)
    {
        foreach ($second as $key => $value) {
            if ($value instanceof MergeReplaceKeyInterface) {
                $first[$key] = $value->getData();
            } elseif (array_key_exists($key, $first)) {
                if ($value instanceof MergeRemoveKey) {
                    unset($first[$key]);
                } elseif (!$preserveNumericKeys && is_int($key)) {
                    if (!is_scalar($value) || !in_array($value, $first, true)) {
                        $first[] = $value;
                    }
                } elseif (is_array($value) && is_array($first[$key])) {
                    $first[$key] = static::merge($first[$key], $value, $preserveNumericKeys);
                } else {
                    $first[$key] = $value;
                }
            } else {
                if (!($value instanceof MergeRemoveKey)) {
                    $first[$key] = $value;
                }
            }
        }

        return $first;
    }