This might be better. I'm probably still missing some logic. void getSectionsList(TreeKey tk, list l) { l.append (tk->getText()); if tk->hasChildren() { tk->firstChild(); getSectionsList(tk, l); } while tk->nextSibling() { getSectionsList(tk, l); } tk->parent(); } Matthew