I finally was able to use query variables to sort of do this instead, and that works out great for me.
{
var(func: regexp(name, /^some_brand.*$/i)) @filter(has(category)) {
category @filter(has(sublevel) and regexp(name, /^some_device.*$/i)) {
l1 as sublevel {
l2 as sublevel {
l3 as sublevel {
l4 as sublevel {
l5 as sublevel
}
}
}
}
}
}
var(func: uid(l1,l2,l3,l4,l5)) @filter(regex(name, /^sublevel_2_1.*$/i)){
a as uid
pred as _predicate_
}
all(func: uid(a)) {
expand(val(pred)) {
expand(_all_)
}
}
}
Thank you @MichelDiz for your help!