return em;
} else {
Path closestArray = arrName.prefix(-(lastAny + 1));
Path oldPrefix = nestedFieldPrefix;
nestedFieldPrefix = arrName.suffix(-(closestArray.numSegments() + 1)).prefix(-1);
<BUG>QueryExpression em = iterate(q.getElemMatch(), context);
</BUG>
nestedFieldPrefix = oldPrefix;
if (em instanceof TruePH
|| em instanceof FalsePH) {

return em;
} else {
Path closestArray = arrName.prefix(-(lastAny + 1));
Path oldPrefix = nestedFieldPrefix;
nestedFieldPrefix = arrName.suffix(-(closestArray.numSegments() + 1)).prefix(-1);
QueryExpression em = iterate(q.getElemMatch(), newContext);
nestedFieldPrefix = oldPrefix;
if (em instanceof TruePH
|| em instanceof FalsePH) {
