Sounds like you want a queue of things to do next then.
- List of things to process in the next iteration = startstring
- While there are things to process in the next iteration
- things to process this iteration = things to process next iteration. Things to process next iteration = ()
- while things to process this iteration
- shift list of things to do this iteration, and split that thing
- ponder the split thing and print any revelations.
- add to the list of things to process next iteration if appropriate
You probably don't want to do recursion if you want to print everything from one level before moving on to the next.