private void findCorrelationEquivalent(CorRef correlation, RexNode e)
          throws Util.FoundOne {
    if(e instanceof RexCall){
      switch (e.getKind()) {
      case AND:
        for (RexNode operand : ((RexCall) e).getOperands()) {
          findCorrelationEquivalent(correlation, operand);
        }
      default:
        final RexCall call = (RexCall) e;
        final List<RexNode> operands = call.getOperands();
        if(operands.size() == 2) {
          if (references(operands.get(0), correlation)
              && operands.get(1) instanceof RexInputRef) {
            // if call isn't EQUAL type and it has been determined that value generate might be
            // required we should rather generate value generator
            if(e.getKind() != SqlKind.EQUALS && (boolean)valueGen.peek()) {
              return;
            }
            throw new Util.FoundOne(Pair.of(((RexInputRef) operands.get(1)).getIndex(),
                Pair.of(((RexCall) e).getOperator(), true)));
          }
          if (references(operands.get(1), correlation)
              && operands.get(0) instanceof RexInputRef) {
            // if call isn't EQUAL type and it has been determined that value generate might be
            // required we should rather generate value generator
            if(e.getKind() != SqlKind.EQUALS && (boolean)valueGen.peek()) {
              return;
            }
            throw new Util.FoundOne(Pair.of(((RexInputRef) operands.get(0)).getIndex(),
                Pair.of(((RexCall) e).getOperator(), false)));
          }
          break;
        }
      }
    }
  }
Finds a {@link RexInputRef} that is equivalent to a {@link CorRef},
and if found, throws a {@link Util.FoundOne}.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRelDecorrelator.java