Script fails after 4th iteration
A couple of things

You are not freeing your bmesh s with

bm.free


you need to call the free method

bm_now.free()
bm_next.free()


Also consider replacing bpy.ops.object.duplicate(linked=False) with either:

newobj = bpy.context.object.copy()
newobj.data = newobj.data.copy()
bpy.context.scene.objects.link(newobj) # link it to scene
bpy.context.scene.objects.active = newobj # make it context.active_object


or quite simply

mesh = bpy.context.object.data


to not have subdivided dupes.

Not using operators will avoid adding the state to the undo stack, and running out of memory.  

Making these changes lets me get to 8 on default cube, (9  crashes my blender), which is passable  given 6 is the max for modifier.