XPath: how to check grand parent of Case in Lookup Table

I think this forum post should help in setting up an expression to iterate over grandchildren.

In your case, if you are inside of a form already you'll want to swap any references to

current()/@case_id

with

instance('commcaresession')/session/data/case_id

to reference the ID of the grandparent case.