Is it a uniquely human ability?
Sometimes we are planning to do something and are about to start, when we are interrupted and have to do something else first. Most of us have heard requests like “Before you take your shoes off, could you please take out the garbage?”
Or we may even interrupt ourselves, by deciding that some action that we are planning necessitates our doing something else first. We might plan to paint a room in our house and be preparing to do so, when we notice that the walls of the room have some holes that need to be patched. Then, preparing to patch a hole, we may notice that there is a mouse inside it. After making the hole larger to remove the mouse, we may see that a whole family of mice has made a home inside the wall, and worse, we may see that the framing of the house inside the wall is rotten. Only after undertaking major renovations to the house do we finally return to painting the (same?) wall that we started with.
Such cases of “indefinite regression” are common in human behavior, but I doubt that many other animals are capable of them — that is, of holding one or more intentions in suspension (“keeping them in mind”) until we have accomplished other goals that we thought of later but must act on earlier.
Recursive problem solving is a special case of such thinking. It involves taking a problem and solving it by solving one or more smaller problems of the same kind first, and then completing the solution of the larger problem, using the solution(s) to the smaller problem(s).
Sometimes we do that by using dividing a problem into smaller sub-problems and using human assistants. If we want to collect 100 donations from people on the street, we may be able to get 10 people to collect 10 donations each, and some of those people may be able to get 2 people to collect 5 donations each. (I’m using “collecting donations” as a more socially acceptable example than “selling street drugs”.)
A special case of recursive problem solving involves just one problem solver. For example, as a common saying goes, “The longest journey begins with a single step.” That can be expanded into a little recursive algorithm, which I will call Journey N steps. The algorithm can be written in two different versions: