Our local pool actually has a posted rule about this and they are very strict. In the changing room area, no child over the age of 3 (4 and up) can go into the opposite sex area, regardless of reason. They even hire staff to help the parents in a predicament out by taking kids into the washrooms and helping them change their clothes and such. Apparently a few years ago this was becoming a huge issue. Moms were taking their even preteen sons, into the female areas to change clothes. Women were feeling very uncomfortable with this as swimsuits are often taken off and it is not uncommon for women to walk from a changing room naked into the shower area or be in various levels of nakedness while changing.
Of course the above is a very different situation than a bathroom, but I just wanted to throw it in there.