Can someone explain me how exactly the flow is working?

Yes, recursion is very confusing. Don’t be alarmed if it takes a while to sink in. There have been some recent threads where I’ve tried to explain this solution, here and here. Take a look at those and see if those help. If not, let us know.