A prescription for the removal of Compton-scattered gamma rays from gamma-ray spectra