docs: @VisibleForTesting
    static List<String> genCandidateBaseNamesForExpr(ExprNode exprNode) {
      if (exprNode instanceof VarRefNode || exprNode instanceof DataAccessNode) {
        List<String> baseNames = Lists.newArrayList();
        String baseName = null;
  
        while (exprNode != null) {
          String nameSegment = null;
          if (exprNode instanceof VarRefNode) {
            nameSegment = ((VarRefNode) exprNode).getName();
            exprNode = null;
          } else if (exprNode instanceof FieldAccessNode) {
            FieldAccessNode fieldAccess = (FieldAccessNode) exprNode;
            nameSegment = fieldAccess.getFieldName();
            exprNode = fieldAccess.getBaseExprChild();
          } else if (exprNode instanceof ItemAccessNode) {
            ItemAccessNode itemAccess = (ItemAccessNode) exprNode;
            exprNode = itemAccess.getBaseExprChild();
            if (itemAccess.getKeyExprChild() instanceof IntegerNode) {
              // Prefix with index, but don't add to baseNames list since it's not a valid ident.
              IntegerNode keyValue = (IntegerNode) itemAccess.getKeyExprChild();
              if (keyValue.getValue() < 0) {
                // Stop if we encounter an invalid key.
                break;
              }
              nameSegment = Long.toString(keyValue.getValue());
              baseName =
                  BaseUtils.convertToUpperUnderscore(nameSegment)
                      + ((baseName != null) ? "_" + baseName : "");
              continue;
            } else {
              break; // Stop if we encounter a non-static key
            }
          } else {
            break; // Stop if we encounter an expression that is not representable as a name.
          }
  
          baseName =
              BaseUtils.convertToUpperUnderscore(nameSegment)
                  + ((baseName != null) ? "_" + baseName : "");
          baseNames.add(baseName); // new candidate base name whenever we encounter a key
        }
        return baseNames;
      } else if (exprNode instanceof GlobalNode) {
        String[] globalNameParts = ((GlobalNode) exprNode).getName().split("\\.");
  
        List<String> baseNames = Lists.newArrayList();
        String baseName = null;
        for (int i = globalNameParts.length - 1; i >= 0; i--) {
          baseName =
              BaseUtils.convertToUpperUnderscore(globalNameParts[i])
                  + ((baseName != null) ? "_" + baseName : "");
          baseNames.add(baseName);
        }
        return baseNames;
  
      } else {
        // We don't handle expressions other than data refs and globals.
        return ImmutableList.of();
      }
    }