OK, I will break this down the way I process it and keep the specific code out of it.
When I call my function, I pass it the URL for the endpoint (https://n11.meraki.com/api/v0/networks/N_555555555555555/clients) and the query information (timespan=30&perPage=1000)
The function starts a loop and calls the endpoint with this data. The first 1000 entries are returned. It saves that data. It then looks at the header.list and checks for "rel=next". If it finds it, it then gets whatever the token value is associated and then modifies the query to include it, using your example (timespan=30&perPages=1000&startingAfter=ka1710e)
It then goes back to the top of the loop, checks to see if it is done, and then calls the endpoint again with the new query values. It gets the next 1000 clients and concatenates the data to the end of the previous page. Then it checks for "rel=next" again. If it finds it, it gets the new token (k17db29) and updates the query to be timespan=30&perPages=1000&startingAfter=k17db29)
It goes to the top of the loop and sees it is not done. Calls the endpoint again with this query. Get the next page of data and concatenates it. Let's say this is the last page. It checks for "rel=next" and does not find it. It sets the flag to tell the loop it is done and returns to the top of the loop. The loop sees it is done and exits the loop. The function then returns all of the data it collected (3 pages worth) so it can be processed.
Does that make it a bit clearer?