Searching for nodes in a huge tree
The simplest way to avoid the recursive traversal is to have two lists: nodes you want to visit and nodes you have visited. Your loop then goes like this:


take a node from the 'to visit' list, or end if empty
check the node 
add any connected nodes that aren't in the 'visited' list to the 'to visit' list