Efficient inference of recent and ancestral recombination within bacterial populations