Spend massive amounts of time doing internal work, meditating and practicing mindfulness which enhances objectivity and ability to analyze oneself, do the digging and unearth the buried emotions. Really not easy to do.
Most patterns of behaviors that lead to depression are inflicted by childhood trauma, neglect or whatever. So it’s kind of about finding that inner child and like explaining to it that it’s all good, it’s not the problem, and beginning a process of healing.