for-each-ref: introduce filter_refs()