@msweeney I added unit tests to replicate the issue. I tried creating a fragment with a slightly complicated structure (painful reverting to raw dom) which in turn could clearly demonstrate what was needed.

@juandopazo Absolutely. However, it results in higher chances of blowing the stack (as there is a recursive call on each node visited). Also, because of all the function calls, it slows to a crawl on really large and complex documents. This is mitigated with the choice of an iterative algorithm. Here's a quick performance test I threw together which utilizes Crockford's famous recursive walkTheDOM function vs. iteration: http://jsperf.com/bytags