def _element_matches(element_to_remove: str, element_to_check: str) ->bool:
    """Checks if an element meets the criteria to be removed from list.

    Some attribute elements (eg. macros) can be defined with a number value
    eg. MACRO_SOMETHING=5. If we are then instructed to remove
    MACRO_SOMETHING then this element needs to be recognised and removed
    in addition to exact matches.

    Args:
        element_to_remove: the element as taken from list to be removed from an attribute
        element_to_check: an element that currently makes up part of an attribute definition

    Returns:
        A boolean reflecting whether the element is a match and should be removed
    """
    return (element_to_check == element_to_remove or element_to_check.
        startswith(f'{element_to_remove}='))
