Ahhh I see what you mean. Yes I am hoping that since he was told no that he will not do it again.
It's likely since you busted him, he understands that doesn't please you and it sends a message that you are the leader. But I wouldn't go to say he won't test you again. After all, it's part of who he is, as a creature.
Dogs are not people, and people are not dogs. They don't do things to tick you off. LOL
I said the tree may have been the trigger, but I also mentioned there are many other things that will.
Scent marking is silent communication at work, saying this is my territory and I'm able to defend it. So he's talking not only to outsiders, but insiders as well.
Look up:
pheromones, scent marking
Neutering will not stop it if it become an ingrained behavior. So it's best to discourage it early on.
Some people say, (depending on the situation) that it can be a sign of trouble in the relationship with his owners. Maybe they're acting way too softly, getting lax, and Fido sees it as a opportunity to move up social hierarchy. Dog's don't necessarily fight to move up, they do it subtly and subtle ways that challenge for the lead, which is a whole new subject. Check yourself, are you providing solid leadership?
If I notice it, I discourage it, strongly if in the house. If I'm out walking them, I generally keep them in heel, but as a reward for a "good walk" I let them, "read the pee-mail" and respond in kind.