def METHOD_NAME(style_name, is_bold, is_italic):
    # strip last occurrence of 'Regular', 'Bold', 'Italic' from style_name
    # depending on the values of is_bold and is_italic
    linked_style = deque()
    is_regular = not (is_bold or is_italic)
    for part in reversed(style_name.split()):
        if part == "Regular" and is_regular:
            is_regular = False
        elif part == "Bold" and is_bold:
            is_bold = False
        elif part == "Italic" and is_italic:
            is_italic = False
        else:
            linked_style.appendleft(part)
    return " ".join(linked_style)