In hindsight, the knowledge gap that led one into doing a wrong thing might seem obvious, but in the action, one can hardly notice this precisely because it requires the knowledge that you are lacking. However, Julian Shapiro's "One Level Higher" mental model, which I like to call Optimise the machine, not a cog in it, can help to notice when you are moving in the wrong direction. Ask yourself high-level questions such as:

If you cannot answer these questions, this is a good moment to stop practice and try to find the answers which requires some self-education.

Related: