Reminds me of a function I wrote in php once to traverse directory structures. What I ended up doing was having the function call itself within itself whenever it hit a directory. This is super simplified way of describing what I did:
Code:
function traverseNode(node) {
for(x in node) {
//do whatever with x here
//then see if it has children
if(x.children > 0) {
traverseNode(x);
}
}
}
Though I don't really have any context. You mentioned going right, up, and down so maybe I'm completely misunderstanding what this is.
