def _remove_noop_on_off_italics(collection):
    """Return an equivalent list to `collection`. It removes the italics node
     pairs that don't surround text nodes, if those nodes are in the order:
     on, off

    :type collection: list[_InstructionNode]
    :rtype: list[_InstructionNode]
    """
    new_collection = []
    to_commit = None
    for node in collection:
        if node.is_italics_node() and node.sets_italics_on():
            to_commit = node
            continue
        elif node.is_italics_node() and node.sets_italics_off():
            if to_commit:
                to_commit = None
                continue
        elif to_commit:
            new_collection.append(to_commit)
            to_commit = None
        new_collection.append(node)
    return new_collection
