How do I get over my baby daddy

I’m having such a hard time. I saw my children’s father with another women yesterday at my apartment and I just can’t stop thinking about it it’s consuming me. We already broke up although I was not moved out. We’ve been together for 7 years and he moved on within a few days looking back I think he was staying with her while we were together too. It hurts like hell I just want to stop thinking about it but I don’t know how.