Try a html dom style approach
Allow elements to restrict children that can be appended. When appending children, append to the parent if the current element doesn't allow
More parse
Refactor