public function appChild(&$parent, $child, $msg = '')
    {
        if (empty($parent)) {
            throw new Exception($msg);
        }
        if (! empty($child)) {
            $parent->appendChild($child);
        }
    }