Here's a hint. Don't look into a stall for more than a quick glance to see if it is occupied. Don't put your feet under the stall wall and touch the occupants feet. And don't stick your hand under the stall wall. Doesn't seem to me that any of those behaviors are that difficult to handle.
When one has homo-erotic feelings, one can not stop themselves. Hormones are more powerful than anything.