Trying not to blame myself

My ex and I broke up in April because he mistreated me and was somewhat emotionally abusive. He's depressed and going through a hard time in his life and told me that some of the things he did he didnt realise and he always maintained that his behaviour had nothing to do with me. I did try and try to make him happy and take his mind off his situation but to no avail. I somewhat believe that now but I also can't help but think that I did something to make him treat me like that despite him saying otherwise. I sometimes feel worthless because he didnt treat other people like that and I cant help but blame myself for the way I was treated. Some days I dont blame myself and other days I do and I end up feeling really sad and questioning my worth and confidence. How do I stop doing this and get it in my head that it's really not my fault for the way I was treated?