I think you are on to something Peter.
The first step is to admit that you have these thoughts, desires and emotions that you feel ashamed about.
The next is to place it before God and ask for His help.
And we do need to examine what purity truly looks like.
.I believe king David would be an excellent case study.