def METHOD_NAME(cls, oldFunction, newFunction):
    import types
    count = 0
    for state in cls.States:
        # Note: you can only replace methods currently
        enterFunc = state.getEnterFunc()
        exitFunc = state.getExitFunc()
        # print 'testing: ', state, enterFunc, exitFunc, oldFunction
        if isinstance(enterFunc, types.MethodType):
            if enterFunc.__func__ == oldFunction:
                # print 'found: ', enterFunc, oldFunction
                state.setEnterFunc(types.MethodType(newFunction,
                                                    enterFunc.__self__))
                count += 1
        if isinstance(exitFunc, types.MethodType):
            if exitFunc.__func__ == oldFunction:
                # print 'found: ', exitFunc, oldFunction
                state.setExitFunc(types.MethodType(newFunction,
                                                   exitFunc.__self__))
                count += 1
    return count