when implementing a recursive function during development, i will use a counter and exit if it reaches a certain limit so as not to crash if i make a mistake.
Question: should i keep this in place moving in to production, or should the code be tested so well, that there should be no need for this.
The function in question is a recursive function generating a sitemap. Iterating over a set of nodes which all can have children.
You can’t test everything 100%, but you should test as much as reasonably possible. Look into unit testing, it’s generally a very simple procedure and will help eliminate the majority of bugs.