This is a general function, so move it into utils.general.