That is one fine reason to wear a hat of any kind when you are working.
In my business I often find myself in attics and other places where I often don't notice there is a rafter or support beam.... wooden or metal... right about head level as I'm walking down the walkway in the dark with my flashlight shining on the floor so I can see where I'm stepping.
BANG...
slam right into it with my face or forehead...and sometimes I do kinda stand up right under them too. Hurts quite a bit...... but a hat of any kind will cushion the impact and will keep you from gashing your scalp wide open.
The interesting thing is.... once you slam into the object.... you tend to remember it's there.... sometimes... definitely after the second such impact, it becomes so much easier to remember it's location.