One general technique is to use a stack:
seed the stack with the first instance
while (stack has entries)
pop off top entry from stack
process it
take any potential new work as a result of
processing, put it back on the stack
And depth/breadth first recursion can be adjusted by shifting instead of popping at the top of the loop (or when inserting new work).
Of course this only replaces the subroutine stack with your own, but it can be quicker and save memory. (Sometimes it's a lot more obvious too!)