def annihilate(predicate: tuple, stack: tuple) -> tuple:
    '''Squash and reduce the input stack.
    Removes the elements of input that match predicate and only keeps the last
    match at the end of the stack.
    '''
    extra = tuple(filter(lambda x: x not in predicate, stack))
    head = reduce(lambda x, y: y if y in predicate else x, stack, None)
    return extra + (head,) if head else extra
Squash and reduce the input stack.
    Removes the elements of input that match predicate and only keeps the last
    match at the end of the stack.