In reply to markiv:
There is, but it is quite convoluted.
match_q = bad_idea_q.find_index with ( item.sub_q1.or(q1) with (addr1 >> 4 == q1 >> 4) &&
item.sub_q2.or(q2) with (addr2 >> 4 == q2 >> 4) );
It might be more suitable to write a function.