def get_tups(y, z=[]):
    if y:
        for x in y:
            if isinstance(x, tuple):
                z.append(x)
            else:
                get_tups(x, z)
    return z

for i in xrange(99999):
    print get_tups([('foo',)])