'return the index of the frame/TracebackItem where recursion
originates if appropriate, None if no recursion occurred'

def recursionindex(self):

    cache = {}
    for (i, entry) in enumerate(self):
        key = (entry.frame.code.path, id(entry.frame.code.raw), entry.lineno)
        l = cache.setdefault(key, [])
        if l:
            f = entry.frame
            loc = f.f_locals
            for otherloc in l:
                if f.is_true(f.eval(co_equal, __recursioncache_locals_1=loc, __recursioncache_locals_2=otherloc)):
                    return i
        l.append(entry.frame.f_locals)
    return None
