def get_oldest(class_name):
    """Get the oldest object for a specific class name"""
    for cls, wdict in six.iteritems(live_refs):
        if cls.__name__ == class_name:
            if not wdict:
                break
            return min(six.iteritems(wdict), key=itemgetter(1))[0]
Get the oldest object for a specific class name
stackoverflow/venv/lib/python3.6/site-packages/scrapy/utils/trackref.py