public @Nullable Integer getOtherSelfJoinFactor(int factIdx) {
    HiveLoptMultiJoin.RemovableSelfJoin selfJoin = removableSelfJoinPairs.get(factIdx);
    if (selfJoin == null) {
      return null;
    } else if (selfJoin.rightFactor == factIdx) {
      return selfJoin.leftFactor;
    } else {
      return selfJoin.rightFactor;
    }
  }
Returns the other factor in a self-join pair if the factor passed in is
a factor in a removable self-join; otherwise, returns null.

@param factIdx one of the factors in a self-join pair
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveLoptMultiJoin.java