Match routes iteratively to prevent stack overflows