protected function deepMerge(array $a, array $b)
    {
        $bref_stack = [&$a];
        $head_stack = [$b];

        do {
            end($bref_stack);
            $bref = &$bref_stack[key($bref_stack)];
            $head = array_pop($head_stack);
            unset($bref_stack[key($bref_stack)]);

            foreach ($head as $key => $value) {
                if (strpos($key, '@') !== false) {
                    // Remove @ from the start and the end. Key syntax `import@2` is supported to allow multiple operations of the same type.
                    $list = explode('-', preg_replace('/^(@*)?([^@]+)(@\d*)?$/', '\2', $key), 2);
                    $action = array_shift($list);
                    $property = array_shift($list);

                    switch ($action) {
                        case 'unset':
                        case 'replace':
                            if (!$property) {
                                $bref = ['unset@' => true];
                            } else {
                                unset($bref[$property]);
                            }
                            continue 2;
                    }
                }

                if (isset($key, $bref[$key]) && \is_array($bref[$key]) && \is_array($head[$key])) {
                    $bref_stack[] = &$bref[$key];
                    $head_stack[] = $head[$key];
                } else {
                    $bref = array_merge($bref, [$key => $head[$key]]);
                }
            }
        } while (\count($head_stack));

        return $a;
    }