How would you solve a problem involving recursive tree or graph traversal and then convert it to an iterative approach?