interactivemode: Fix variable access in Python 3.3 with a "smarter" algorithm to find the right context