why don't you use something as simple as:

`for (var node = dom.message.firstChild; node; node = node.nextSibling)`

?