Setting max recursion limit to 2500 (via sys.setrecursionlimit: http://docs.python.org/library/sys.html#sys.setrecursionlimit) in astvisitor.ASTVisitor.visit_node makes it work. Documentation page says that "the highest possible limit is platform-dependent" and doesn't mention what are the values for different platforms, so we should research that before making a change.
Still, that's only a workaround. Maybe there's a way to make lib2to3.pytree.WildcardPattern._recursive_matches iterative? That would fix the problem once and for all.