The OP has it right. I've been programming almost 40 years, and I think it's safe to say I've achieved a certain level of mastery. But when I'm working on something hard, I still feel lost and stupid. I wouldn't have it any other way! If I don't feel challenged, I get bored really really fast.
Patience, and a confidence that comes from having solved hard problems before. If there's a trick, it's to always focus on the part that doesn't make sense yet.