Italy's highest court has ruled that masturbation in public is not a crime, as long as it is not conducted in the presence of minors.