Your if-statement should be:
if "x" not in sticky.keys():
But I think that’s unrelated to the thrown exception.
This exception might be related to a Grasshopper bug that was recently mentioned here on the forums.
I often encountered the same exception when I launched Rhino and Grasshopper in tandem on macOS by double-clicking a Grasshopper file with Python components on the canvas. It doesn’t happen, when I first launch Rhino, then Grasshopper from within, and finally open the relevant file.