def is_modified_terminal(v):
    """Check if v is a terminal or a terminal wrapped in terminal modifier types."""
    while not v._ufl_is_terminal_:
        if v._ufl_is_terminal_modifier_:
            v = v.ufl_operands[0]
        else:
            return False
    return True
