public function removeSelf()
    {
        $tmp = dom_import_simplexml($this);

        if ($tmp->isSameNode($tmp->ownerDocument->documentElement)) {
            throw new BadMethodCallException('removeSelf() cannot be used to remove the root node');
        }

        $node = $tmp->parentNode->removeChild($tmp);
        return simplexml_import_dom($node, get_class($this));
    }