Shouldn't $span->parentNode->parentNode->replaceChild($h1, $span->parentNode); do what you want?
In order to add a node after a given node, you can use something like (untested!):
if ($h1->nextSibling) {
$h1->parentNode->insertBefore($h1->nextSibling, $dom->createElement('br'));
} else {
$h1->parentNode->appendChild($dom->createElement('br'));
}