private function end($name)
    {
        $this->last = $this->names->pop();
        if (! is_null($name) && $this->last !== $name) {
            $n = is_string($name) ? $name : 'a bad';
            $msg = 'You tried to close %s section where you should have closed %s.';
            throw new InvalidArgumentException(sprintf($msg, $n, $this->last));
        }

        return $this->stack->pop();
    }