Once an idea comes to you, write it down somewhere and try to forget about it. The idea might seem brilliant at the moment (or at least better than your current task), but it might not seem so good some time later. Give your ideas time to settle, then come back to them and try to assess them again with a fresh look (probably at the beginning of an iteration when you need to plan the next few weeks).
And one more thing that I think could be helpful. Always assume that your new idea is a bad one. Don’t rush to implement it, take your time.
Dump the idea and then reevaluate it, often more than once. Try to mix it in to something else, even if it’s just a nugget.