protected function _containerGet($container, $key)
    {
        $origKey = $key;
        $key     = $this->_normalizeKey($key);
        // NotFoundExceptionInterface#getDataKey() returns `string` or `Stringable`,
        // so normalize only other types, and preserve original
        $origKey = is_string($origKey) || $origKey instanceof Stringable
            ? $origKey
            : $key;

        if ($container instanceof BaseContainerInterface) {
            try {
                return $container->get($key);
            } catch (NotFoundExceptionInterface $e) {
                throw $this->_createNotFoundException($this->__('Key "%1$s" not found', [$key]), null, $e, null, $origKey);
            }
        }

        if ($container instanceof ArrayAccess) {
            // Catching exceptions thrown by `offsetExists()`
            try {
                $hasKey = $container->offsetExists($key);
            } catch (RootException $e) {
                throw $this->_createContainerException($this->__('Could not check for key "%1$s"', [$key]), null, $e, null);
            }

            if (!$hasKey) {
                throw $this->_createNotFoundException($this->__('Key "%1$s" not found', [$key]), null, null, null, $origKey);
            }

            // Catching exceptions thrown by `offsetGet()`
            try {
                return $container->offsetGet($key);
            } catch (RootException $e) {
                throw $this->_createContainerException($this->__('Could not retrieve value for key "%1$s"', [$key]), null, $e, null);
            }
        }

        if (is_array($container)) {
            if (!array_key_exists($key, $container)) {
                throw $this->_createNotFoundException($this->__('Key "%1$s" not found', [$key]), null, null, null, $origKey);
            }

            return $container[$key];
        }

        if ($container instanceof stdClass) {
            // Container is an `stdClass`
            if (!property_exists($container, $key)) {
                throw $this->_createNotFoundException($this->__('Key "%1$s" not found', [$key]), null, null, null, $origKey);
            }

            return $container->{$key};
        }

        throw $this->_createInvalidArgumentException($this->__('Not a valid container'), null, null, $container);
    }