Fix to avoid attribute name clash between Document/HTMLDocument

Use children() instead of traverse_preorder(), and avoid having
GetHead() in both Document and HTMLDocument.

Closes #1465.