Start writing concrete things that need to be reinforced, that are easy to answer and can be connected together. Things like the goal of the software, core modules, what you're working on now, etc. Expand to things like what new features would be nice, how to implement them, etc.
This works better than vague solutions like "do one thing" because where do you start? Writing a line of code somewhere for the sake of it is pointless. Especially if it's bad code, that just makes me feel worse knowing I'll probably have to undo it later because that's usually what ends up happening based on past examples.
Detaching yourself from the work frees you from all the things tying you down that clouds your mind. Taking a moment to reorganize gives you a new thing to focus on, and arms you with purpose which makes it easier to work.