Immediate T for having 5 1/2 players on the floor!
You handled it well enough, it sounds like. This won't be the last time somebody or some thing comes onto the court during play. Your overriding concern will always be safety. In the case of a small child, you have that child's safety to consider. But depending on the circumstances, the child and/or the parent, may also pose a risk to the players.
The Jurassic one has spoken much wisdom. If you clearly can remedy the situation without stopping play, then do so. If you cannot, or you have reasonable doubt about your ability to do so, then stop play.