public function pop($path)
    {
        $node = $this->get($path);

        if (\is_object($node)) {
            $node = get_object_vars($node);
        }

        if (!\is_array($node)) {
            throw new \UnexpectedValueException(
                sprintf(
                    'The value at path: %s should be object or array but is %s.',
                    $path,
                    \gettype($node)
                )
            );
        }

        $value = array_pop($node);

        $this->set($path, $node);

        return $value;
    }