protected function merge($key, $result)
    {
        if (is_null($key)) {

            // key is null, so just merge with root
            $this->config = array_merge($this->config, $result);

        } elseif (strpos($key, '.') === false) {

            // non-compound key, just merge key with incoming data
            if (!isset($this->config[$key]) && !array_key_exists($key, $this->config)) {
                throw new KeyDoesNotExistException($key);
            }

            // if $this->config[$key] is not an array, we convert it one before merging
            if (!is_array($this->config[$key])) {
                $this->config[$key] = [];
            }

            $this->config[$key] = array_merge($this->config[$key], $result);

        } else {

            // compound key, so merge with parent reference
            list($parent, $child) = $this->getParentChildKeys($key);
            $config = $this->resolveKey($parent);
            $config[$child] = array_merge($config[$child], $result);

        }
    }