This is great, thank you for creating it. So easy to use.
I was doing a query from the main site in a network and I found that, during a loop, having two posts from the same child site would reset the current blog to the network.
The fix is to replace the "else" in switch_to_blog_while_in_loop() with:
else if ( ! ms_is_switched() )
... that way, if the current blog id is that of a child blog, it will stay there instead of switching back by using restore_current_blog().