def METHOD_NAME(self, instance, max_iter=5, reversible=True):
    """
    Apply the transformation.  This is called by ``apply_to`` in the
    superclass, and should not be called directly.  ``apply_to`` takes the
    same arguments.
    Args:
        instance: A block or model to apply the transformation to
    Returns:
        None
    """
    self.reversible = reversible
    if reversible:
        self._instance = instance
        self._all_subs = []
        self._subs_map = {}
        self._expr_map = {}
        self._all_fixes = []
        self._all_deactivate = []
        self._original = {}
        # The named expressions could be changed as a side effect of the
        # constraint expression replacements, so for maximum safety, just
        # store all the expressions for Expressions
        for c in instance.component_data_objects(
            pyo.Expression,
            descend_into=True,
        ):
            self._original[id(c)] = c.expr
            self._expr_map[id(c)] = c
    nr_tot = 0
    # repeat elimination until no more can be eliminated or hit max_iter
    for i in range(max_iter):  # pylint: disable=unused-variable
        subs, cnstr, fixes, subs_map = self._get_subs(instance)
        if reversible:
            self._all_fixes += fixes
            self._all_deactivate += cnstr
            self._all_subs.append(subs)
            self._subs_map.update(subs_map)
        nr = len(cnstr)
        if nr == 0:
            break
        nr_tot += nr
        for c in cnstr:  # deactivate constraints that aren't needed
            c.deactivate()
        for v in fixes:  # fix variables that can be fixed
            v[0].fix(v[1])
        # Do replacements in Expressions, Constraints, and Objectives
        # where one var is replaced with a linear expression containing
        # another
        vis = EXPR.ExpressionReplacementVisitor(
            substitute=subs,
            descend_into_named_expressions=True,
            remove_named_expressions=False,
        )
        for c in instance.component_data_objects(
            (pyo.Constraint, pyo.Objective), descend_into=True, active=True
        ):
            if id(c) not in self._original and reversible:
                self._original[id(c)] = c.expr
                self._expr_map[id(c)] = c
            c.set_value(expr=vis.walk_expression(c.expr))
    _log.info("Eliminated {} variables and constraints".format(nr_tot))