I agree, and I think there is no such coding as 'take everyone scored above the average and add him in that level'. That would be recursive, self-destroying and contradicting: Imaging the average in a 8-player top level group is 2000, and there are two players with 2010 and 2100. After adding them in, the average is now 2011, so you need to take the first one back out? Or if you don't do that, the list of players that are 'in' depends on the sequence you add them. Also, it could happen that there are a hundred players with score higher than that average, so you end up with a single group of 100+ players?
The code - and yes, this is a guess, but I'm pretty sure - takes the participants from last Championship that made the cut (1-5 or whatever), adds the ones that were in the go-up ranks of the next lower level (2 times 1-2), ignoring all those that don't want to participate, of course.
Then, if there are empty slots, they are filled with the highest ranking participants, excluding only those that were on a go-down slot last Championship.
Repeat for next league, etc.
That means if there are lots of dropouts in higher leagues, you could end up being pretty low positioned in league 4, and still playing league 3, 2, or even 1 next time.
If this seems inappropriate - think again, on who else should get into that slot? I think it is a pretty good and fair solution.
Be aware that this opens a way into first league if you are not able to win second league - you opt out for one Championship, make sure you have a top rating, and you then opt back in. Chances are high that there is a slot in league 1 (someone always drops out), and you will get in.