A lot of great answers here with reasons why you should but just to cover all aspects, why you shouldn't:
- Recursive functions only implicitly stop execution which can cause unexpected behavior if using sync and async code simultaneously or when using async recursion (admittedly not relevant for JSX scripting)
- Recursion is exponentially harder to debug and understand the full boundaries of while reading either for someone else or your future self a few months from now
- Recursion is exponentially more error and bug-prone
- Recursion is exponentially slower because it adds to the callstack per lookup and descendant, resulting in several redundant function calls and loops
The only time recursion should be used (at least for me in my own code) is when necessary: we're working with nestable objects or dynamic user-generated content and we cannot account for the complexity of depth/nesting, we're not using a rigid structure. This could be pageItem contents or folder/files contents as noted or it could be an HTML DOM where recursion is necessary to ensure accurate non-shallow results, but it could also be completely gratuitous and a way to shoot yourself in the foot multiple times if you try implementing recursion in cases when unneeded.
For practice, there's no harm in playing with recursion liberally no matter what the case is just to refine your own skills and understanding. However for production since recursion can be such a double-edged sword, you have to consider the fact that adding it can be the source of several near-future patches and bugs (from unexpected parameters fed into your recursive function args) or that using it in a document with thousands of entries might take 10x longer to do the same thing as a shallow lookup.