def FilterBlocks(blocks, filter_func):
  """Gets rid of any blocks if filter_func evaluates false for them.

  Args:
    blocks: [(offset1, offset2, size), ...]; must have at least 1 entry
    filter_func: a boolean function taking a single argument of the form
                 (offset1, offset2, size)

  Returns:
    A list with the same structure with entries for which filter_func()
    returns false removed.  However, the last block is always included.
  """
  # We retain the 'special' block at the end.
  res = [b for b in blocks[:-1] if filter_func(b)]
  res.append(blocks[-1])
  return res