protected function wrapInNode($nodeType, $callback)
    {
        // Sanity check
        assert(is_string($nodeType));
        assert(is_callable($callback));

        $this->startElement($nodeType);
        $result = $callback();
        $this->endElement();

        return $result;
    }