public function getWrapperNodes($template, &$simple)
{
$wrapper = $template->cloneNode(TRUE);
$targets = NULL;
$target = NULL;
if (!$simple) {
// get the first element without child elements.
$targets = $this->getOwner()->xpath('.//*[count(*) = 0]', $wrapper);
}
if ($simple || $targets->length === 0) {
$target = $wrapper;
$simple = TRUE;
} elseif ($targets instanceof \DOMNodeList) {
$target = $targets->item(0);
}
return array($target, $wrapper);
}