protected function cloneChildren(Heading $node)
{
$firstClone = clone $node;
// We have no choice but to hack into the
// system to reset the parent, previous and next
$this->setNull($firstClone, 'parent');
$this->setNull($firstClone, 'previous');
$this->setNull($firstClone, 'next');
// Also, the child elements need to know the next parents
foreach ($firstClone->children() as $subnode) {
$method = new ReflectionMethod(get_class($subnode), 'setParent');
$method->setAccessible(true);
$method->invoke($subnode, $firstClone);
}
$deepCopy = new DeepCopy();
return $deepCopy->copy($firstClone)->children();
}