I’ve found that some encouraging words to a parent obviously stuck in that situation helps. Somebody did that for me when I was a brand-new parent and it gave me the strength to get through it without doing something stupid.
Now that girl, who screamed for an hour outside of the laundromat when she was about a year old, is perfectly behaved.
I also noticed that if a parent is angry or frustrated, speaking soothingly to the child snaps the parent back from the “edge”. It’s surprising the patience they find to soothe their own child and quiet them when encouraged by someone else.
Sadly, I lost my little whistle that used to hang on my keychain and haven't found another so sweet-sounding -- like a little flute. I often would tootle it gently near a crying child in a store to distract their attention from their snit. They would almost always quiet down to try to hear it, then I would toot it again and start speaking to them soothingly, as long as the mother was right there (I am a mom). Many times they would calm down, or at least catch a breath. Most mothers were grateful.