There are cues to listen for to know that our hunger/desire is for a good feeling and not for food.
The next time you are feeling ravenously hungry, and you really want to eat -- ask yourself if you could eat an apple.
If your body/mind/spirit screams, "No, chocolate cake!!!" that is your clue that this isn't a body hunger.
Your body would rather have an apple. It can get really great energy from it very easily.
Your mind/spirit really wants you to give yourself cake. But that cake doesn't make your mind/spirit fat. Your mind/spirit experiences the cake at the sensory level. It feels the rush of endorphins that you release even thinking about tasting the cake. And it wants to be flooded with those good feelings. Those feelings, that pleasure is a sign of love and comfort.
Your mind/spirit has been taught to recognize your love in the form of a piece of cake, or a cookie, or a bag of chips, or whatever your treat is... but the key to rescuing yourself from a never ending battle between what your body needs and what your mind/spirit needs is to recognize that you are looking for something really enjoyable.
If you like going for a walk, then offering it a walk instead will work. If you hate walking -- then no dice.
You need to listen to your desire behind the surface desire.
How many things do you like / want in life that aren't food?
Those other things aren't usually as convenient to buy in the moment. Our desire to give ourselves a treat explains why we have machines that dispense treats at work. And they aren't usually stocked with fresh fruit. If you work in an office, you probably have a vending machine. The things in the vending machine are typically that great sugary instant feel better stuff.
One way I lost weight was to become more of a connoisseur, some days, having a snickers now compared to having a See's chocolate chip truffle later is worth waiting for. And more often not, that later becomes another time.