I gained 40 pounds between August 2008 and August 2009 after having lost the same 40 pounds slowly over the previous five years. I'm still not quite sure what happened, but it certainly involved a lot of binge eating.
What stopped it was reading
The End of Overeating by David Kessler. That gave some righteous anger against the food industry for marketing junk specifically designed to turn overeaters like me into addicts. And, it gave me the tool of making rules to stop my worst behaviours.
Having experienced some success with dealing with the behavior of overeating (rather than a lot of analyzing about the whys and wherefores), I got Judith Beck's books from the library next. She's kind of the go-to gal of using Cognitive Behavior Therapy techniques for weight loss. What's helped me the most from her book is planning my meals ahead of time. It reduces my decision-making and stress and I find I can just pass by things that aren't on my plan.