I wouldn't do that thing at all, I'd try not thinking of it.
I'd travel to another juridiction/state/country where it's legal and only do it there.
I'd relieve myself with porn related to the activity.
I'd do it if it doesn't bother anyone else.
I'd do it if it doesn't physically harm someone else.
I'd do it even it bothers someone else.
I'd do it even it harms someone else.
I'd try not to do it, and get some sort of treatment to lessen my desire for it.
KSP - you know so much about me. But I bet you've never seen my collection of rare medieval instruments. I keep it down here, in the basement. Musical instruments? No no, not that kind of instruments ...
Other option (detail in comments)