Is there a way you can get a performance benchmark around something like this? Is using a node iterator faster than two calls to rootElement.getElementsByNS(...)? I haven't measured, just interested to know, as domUtils.getElementsByNS would avoid lot of the subsequent branching as well.

I've just compared the performance of this to current master, and on a document with no annotations, there is no noticable impact @ 1000pages (http://ci.kogmbh.com/deploy/WebODF/webodf-ci-b198-gd4f50bd3/benchmark/?fileUrl=1000pages.odt&colour=red), which is a good thing ;).