This is the thing. You think about something with compulsion for long enough, it shows up in your dreams.
And, it works the same with us 'normal' people, even though the results are less spectacular. Want to have a good idea? You need to feed your brain everything you can and obsess over it, then let it stew for a bit. Again, and again. Only then do you stand a chance for a really good idea to just pop out.