Is it possible to use find_index() functions to match nested queues?

In reply to dave_59:

Function match should return a queue of matching indexes of the bad_idea_q which holds sub_q1==addr1 and sub_q2[y]==addr2.

int match_q[$];
bit stage1, stage2;
foreach(bad_idea_q[i]) begin
 stage1 = 0;
 stage2 = 0;
 foreach(bad_idea_q[i].sub_q1[j]) begin
  if(bad_idea_q[i].sub_q1[j] == addr1) stage1=1;
 end
 foreach(bad_idea_q[i].sub_q2[k]) begin
  if(bad_idea_q[i].sub_q2[k] == addr2) stage2=1;
 end 
 if(stage1&&stage2) match_q.push_back(i);
end


Here’s an example
There are 4 items in the bad_idea_q: {1,2,3,4}
Every item has two sub queues, sub_q1 and sub_q2
item → {sub_q1} {sub_q2}
1 → {a,b,c,d} {e,f,g,h}
2 → {e,f,g,h} {i,j,k,l}
3 → {a,b,c,d} {e,f,g,k}
4 → {e,f,g,h} {l,m,n,o}

Output of match(a,g) → {1,3}
Output of match(a,k) → {3}
Output of match(e,l) → {2,4}
Output of match(e,j) → {2}


Its straightforward to match in a single level search. Curious if there’s a way to simplify searching through the sub queues without a dedicated function. I hope that helped clarify my earlier question