Switch to a loop; forgot Python couldn't do recursion.