What I usually do is

  1.     start working on the question,
  2.     develop it in the direction I think it should go, namely, I play with the question and form the answer the way I think it should be in guidelines.
  3.     Then, I have a better understanding of the problem
  4.     I go and search for topics that could mention facets of my problem.
  5.     Normally, I find something that is not too close but gives me a thread of literature to follow for a while.
  6.     Then, I go and revise what I have done, and progress is made much farther than before.
  7.     Then, I again go back and look for more relevant topics. Normally, at this stage (third iteration of going to literature) I find things that are really close, so close it is a little scary at first - was I scooped 3 years ago??
  8.     Then, normally, I look closer and see that they really did something slightly different, and that my results have better performance in some ways, and that also I can answer questions that the previous guys did not. I summarize these differences. NOTE: Many researchers run out of steam at this point, and just are satisfied with their little advance. This is where most peope are when a conference paper is due, and they have to decide if their progress is good enough.
  9.     At that point (depending on how better my work is and how different) I usually revise the work completely and from a different perspective. Here comes the importance in choosing a question that is good enough from a scientific perspective. Just ask yourself what is the next step after this work is complete. If your competitors did a good job in ansewring the question, then your in an even better position than before because you can now build on their work. If they did not do such a good job, then it is your challenge to do the work such that others (and you) can build on it. Build what? Whatever you had in mind that helped you choose the research question in the first place (see the previous section on choosing a research question).
  10.     At this point you have gained enough insight into the technical problem that you can see and come up with much more mature results, and rewrite your work in a form that is close to the final version. Perhaps one more iteration of "find related work", "explain my findings and my question clearly", and "motivate by telling people the greater story". Remember, you are writing this paper for people other than yourself.

All of this process normally takes around half a year (normally distributed around that 1/2 year mean).