I think what @Rahul has suggested should work, another way to write those queries would be as follows:
#We store cabinets from the device with a given inventory number in a variable `cabinets`
var(func: eq(inventory_number, 123)){
cabinets as has_cabinets
}
#We store the relevant cabinet_keys from the `cabinets`
var(func: uid(cabinets)){
cabinet_keys as ~has_access
}
#Finally get client_ids which have access to the above keys.
GetUsers(func: uid(cabinet_keys)){
~has_keys{
uid
client_id
}
}