factor out filter-by option for collections.

@maxfliri
@abersager