for k, g in itertools.groupby(c):
    if len(list(g)) > 1:
        return k
return None
c = list(range(0, 10000000))
c[5000] = 0
for i in range(0, 10):
    pass
Python: find a duplicate in a container efficiently