'Removes the given block if it satisfies the removal_condition.
Returns True if the block was retained, and False if the block
was removed.
Arguments:
block_key (usage_key) - Usage key of the block.
removal_condition ((usage_key)->bool) - A function that
takes a block\'s usage key as input and returns whether
or not to remove that block from the block structure.
keep_descendants (bool) - See the description in
remove_block.'

def retain_or_remove(self, block_key, removal_condition, keep_descendants=False):

    if removal_condition(block_key):
        self.remove_block(block_key, keep_descendants)
        return False
    return True
