Extract `contains-some` function