public static List<CompiledValue> collectCompiledValuesInThePath(CompiledValue expr,
      ExecutionContext context) throws AmbiguousNameException, TypeMismatchException {
    boolean toContinue = true;
    List<CompiledValue> retList = new ArrayList<>();

    int exprType = expr.getType();
    while (toContinue) {
      switch (exprType) {
        case OQLLexerTokenTypes.RegionPath:
          retList.add(expr);
          toContinue = false;
          break;
        case OQLLexerTokenTypes.METHOD_INV:
          retList.add(expr);
          CompiledOperation operation = (CompiledOperation) expr;
          expr = operation.getReceiver(null/*
                                            * pass the ExecutionContext as null, thus never
                                            * implicitly resolving to RuntimeIterator
                                            */);
          if (expr == null) {
            expr = operation;
            toContinue = false;
          }
          break;
        case CompiledValue.PATH:
          retList.add(expr);
          expr = expr.getReceiver();
          break;
        case OQLLexerTokenTypes.ITERATOR_DEF:
          retList.add(expr);
          toContinue = false;
          break;
        case OQLLexerTokenTypes.TOK_LBRACK:
          retList.add(expr);
          expr = expr.getReceiver();
          break;
        case OQLLexerTokenTypes.Identifier:
          CompiledID cid = (CompiledID) expr;
          expr = context.resolve(cid.getId());
          break;
        default:
          toContinue = false;
          break;
      }

      if (toContinue) {
        exprType = expr.getType();
      }
    }
    return retList;
  }
Collects all the compiled values in the path , starting from the self at position 0 in the
returned List

@return List of CompiledValues ( includes the RuntimeIterator)
geode-core/src/main/java/org/apache/geode/cache/query/internal/PathUtils.java