Two words... variable system.
You script the objectives to add a +1 value to a specified variable. You have a script that runs in a trigger (or attached to a dynamic entity (can be hidden)) to check the variable value. When it reaches a certain level, it can call the command "nextlevel=x". In that "bonus level", you script it so that it will return back to the previous level. You can also script it to carry any variables from the bonus level back to level 5.
It does work, as the "traversing levels" demo I did is a clear example of the system working. It involves a lot of scripting and ensuring the right script(s) is/are doing what they are suppose to without conflict.
I have something similar in design in a development (but it is in level 10 and the "bonus level" is level 11). In level 10, the player will collect items. If the value I've set is reached, the "bonus level" is loaded and they can play it. Upon return, I have variables that transfer back to level 10 and are applied for them to carry on.
There's no problem that can't be solved without applying a little scripting.