They found that daydreaming 'is an important cognitive state where we may unconsciously turn our attention from immediate tasks to sort through important problems in our lives'.
...
The upshot of the research is that, if you're struggling to solve a complex problem, you might be better off switching to something less taxing and letting your mind wander.
Daydreaming? You're actually solving complex problems • The Register