code: def FilterCollection(aff4_collection, offset, count=0, filter_value=None):
    
  
    if offset < 0:
      raise ValueError("Offset needs to be greater than or equal to zero")
  
    if count < 0:
      raise ValueError("Count needs to be greater than or equal to zero")
  
    count = count or sys.maxsize
    if filter_value:
      index = 0
      items = []
      for item in aff4_collection.GenerateItems():
        serialized_item = item.SerializeToString()
        if re.search(re.escape(filter_value), serialized_item, re.I):
          if index >= offset:
            items.append(item)
          index += 1
  
          if len(items) >= count:
            break
    else:
      items = list(itertools.islice(aff4_collection.GenerateItems(offset), count))
  
    return items
docs: Filters an aff4 collection, getting count elements, starting at offset.