Become the alpha. Most people think cats will just do what they want but that isn't true. Cats respect the alpha male hierarchy and I have used it for years with great success. It doesn't require things like harming the animal either.
The first thing to learn is staring. Every time a cat sees another cat they will make eye contact. It doesn't matter if they have lived in the home for 10 years together or never seen each other. Cats use that as an early determination of where they stand with each other. When your cat looks at you , do not look away. Keep staring at it, not blinking, until the cat looks away. With strong willed males you might be surprised how long they will maintain the stare. When the cat looks away , don't stop staring, because many will glance back to see if you were serious. Hold your ground 🙂
Eventually the cat will look down , away , or close its eyes.
From that point the cat will acknowledge you as the alpha, if you raise your voice when you move it off something like the tree using the staring it will remember that. Some cats have strong wills and try to challenge you again later . Remember any time the cat is misbehaving and you just walk over and move the cat and yell at it, that will do no good. When you move it and move away to what you were doing before I guarantee that cat is staring at you and because you didn't object to its challenge it will continue to do what it wants.
I learned this from a zoologist at the NC state zoo. One of the things they tell the workers in the lion area is never to make eye contact if the animal is near. Big cats like lions will maintain the stare and because they feel they are as big as you will attack rather than break the stare. Some people call it blink kissing, where the cat will look at them and the owner can blink slowly and the cat will react with a blink or relaxing posture because you effectively told it everything is okay, I am not upset with you, we are friends.