See the example for firstChild which uses nextSibling to loop through all the items in a tree.