def latestVersionOf(self, anObject):
        """
        Get the latest version of an object.

        This can handle just about anything callable; instances, functions,
        methods, and classes.
        """
        t = type(anObject)
        if t == types.FunctionType:
            return latestFunction(anObject)
        elif t == types.MethodType:
            if anObject.__self__ is None:
                return getattr(anObject.im_class, anObject.__name__)
            else:
                return getattr(anObject.__self__, anObject.__name__)
        elif not _PY3 and t == InstanceType:
            # Kick it, if it's out of date.
            getattr(anObject, 'nothing', None)
            return anObject
        elif _isClassType(t):
            return latestClass(anObject)
        else:
            log.msg('warning returning anObject!')
            return anObject

        Get the latest version of an object.

        This can handle just about anything callable; instances, functions,
        methods, and classes.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/rebuild.py