add debug method for recursive updates

If a widget is added to one of its descendants, this causes the stack to explode due to the instruction updates looping infinitely. Since this causes a segmentation fault, it can be difficult to track down where the problem is happening.

This adds an alternate version of `flag_update` which checks for loops and raises a Python exception, allowing the problem to be examined in a debugger. The alternate version is only activated on a debug build.