def strip_hidden(key_tuples, visibilities):
result = []<EOL>for key_tuple in key_tuples:<EOL><INDENT>if len(key_tuple) != len(visibilities):<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>".format(<EOL>key_tuple, visibilities<EOL>)<EOL>)<EOL><DEDENT>filtered_tuple = tuple(item for item, visible in zip(key_tuple, visibilities) if visible)<EOL>result.append(filtered_tuple)<EOL><DEDENT>return result<EOL>
Filter each tuple according to visibility.

    Args:
        key_tuples: A sequence of tuples of equal length (i.e. rectangular)
        visibilities: A sequence of booleans equal in length to the tuples contained in key_tuples.

    Returns:
        A sequence equal in length to key_tuples where the items are tuples with a length corresponding
        to the number of items in visibility which are True.