protected function _checkDuplicate($name, $config)
    {
        /** @var \Cake\Core\InstanceConfigTrait $existing */
        $existing = $this->_loaded[$name];
        $msg = sprintf('The "%s" alias has already been loaded', $name);
        $hasConfig = method_exists($existing, 'config');
        if (!$hasConfig) {
            throw new RuntimeException($msg);
        }
        if (empty($config)) {
            return;
        }
        $existingConfig = $existing->getConfig();
        unset($config['enabled'], $existingConfig['enabled']);

        $fail = false;
        foreach ($config as $key => $value) {
            if (!array_key_exists($key, $existingConfig)) {
                $fail = true;
                break;
            }
            if (isset($existingConfig[$key]) && $existingConfig[$key] !== $value) {
                $fail = true;
                break;
            }
        }
        if ($fail) {
            $msg .= ' with the following config: ';
            $msg .= var_export($existingConfig, true);
            $msg .= ' which differs from ' . var_export($config, true);
            throw new RuntimeException($msg);
        }
    }