def METHOD_NAME(container, object, app_handle, priority=99):
    """Register an object to be called before a container is traversed.
    'app_handle' should be a string or other hashable value that
    distinguishes the application of this object, and which must
    be used in order to unregister the object.
    If the container will be pickled, the object must be a callable class
    instance, not a function or method.
    'priority' is optional, and determines the relative order in which
    registered objects will be called.
    """
    btr = getattr(container, '__before_traverse__', {})
    btr[(priority, app_handle)] = object
    rewriteBeforeTraverse(container, btr)