Fix the low-level remove/insert hooks and rewrite NodeIterator in terms of it https://www.w3.org/Bugs/Public/show_bug.cgi?id=23268

(NodeIterator could really use some work if someone is up for rewriting
it.)