I'm sure that it depends where you live, but I have a mad technique for dealing with this. I go up to the adult very very politely, and say, "Excuse me, is everything/ are you/ ok?"
Usually what happens is a moment of utter astonishment, and then the adult starts unloading all of his/ her problems onto me and completely forgets the child. Then I walk down the street a short way with them both.
It came to me because a friend from Sierra Leone told me that her people always intervene if a child is being scolded.
Probably I'm just a weird person or I live in a relatively safe neighbourhood: you do have to "act" genuinely concerned despite your own emotional reactions. It seems to, at least temporarily, deflect all that emotional angst from being offloaded on the child.