Prevent infinite loop after backtracking.