Not a problem,
The for loop, starts at the first point the original list exceeds the maximum number of items you want shown in each list. So if there are 21 items in the original list and you only want each list to contain 9 items, it starts at position 9.
It then cycles through the remaining items in the list (or up until the next maximum number of items would be reached). So since there are 21 items in the original list, and we started at position 9, it will run from position 9 to position 18 (9 items, as that is defined as our maximum).
It then takes each item it is looping through and moves it to the New List that was created immediately before the for loop. So now the original list has 12 items and the new list it just created has 9 items.
However, because jQuery caches information, I have to run the currentElement.find('li') statement again and store it back into items so that jQuery now realizes there are only 12 items in the original list, not 21 items.
Then to ensure the 3rd list will show up after the new list of 9 items we just created, I update insertAfterElement to be the list that was just created (instead of the original list of items).
To see the affects of each of these, is quite simple, if you remove the code "&& i < maxItems * 2" from the for loop, you will see the second list it creates (when there are 21 items in the original list) will contain 12 items. So you will have 1 list with 9 items, and a second with 12 items (no third list is created).
To see how jQuery caches the items (just an FYI, this causes an infinite loop), comment out the line "items = currentElement.find('li');". The browser will continuously spin and likely lock up (or ask you to kill the script) because the do-while loop will never exit as jQuery thinks there is always 21 items in the list.
To see how the insertAfterElement plays into account, comment out the line "insertAfterElement = newList;" and you will see the final output being 3 lists, the first containing 9 items, the second, contains 3 items, and the last contains 9 items. Whereas, the expected output is 9 items, 9 items, then 3 items.
Hope this helps.