Iterative removal of redshift-space distortions from galaxy clustering