Ego is a confusing assumption. Your personality is actually a tribe of different selves that come online in relationship to circumstance as you go through life. I call these ‘selves’ parts.
Your parts can be friendly, beneficent, spiritual, and incredibly useful, but equally they can be dysfunctional, traumatized, child-minded, and anything in between.
Each part has it’s own attitude, thoughts, behavior, desires, worldview, and feelings, and these I call it’s scripts. Your parts make up you as a person, and so compassion begins with accepting all the characters inside you. Freedom though, is to become conscious and in charge of when (and if) a part is activated, and who you are moment to moment.
To master this you will need to understand your parts and observe their scripts of behavior. A simple practice you can use anytime is to look for the difference in who you are when with others, with who you are when alone. Or perhaps who you are when angry, with who you are when feeling spiritual. Become mindful and conscious of your behavior, body, thoughts, and feelings throughout your day and you will begin to identify your differing parts and their scripts.