code: private boolean isCandidate(String name, List<Node> refs) {
      if (!OptimizeCalls.mayBeOptimizableName(compiler, name)) {
        return false;
      }
  
      boolean seenCandidateDefiniton = false;
      boolean seenUse = false;
      for (Node n : refs) {
        // Assume indirect definitions references use the result
        if (ReferenceMap.isCallTarget(n)) {
          Node callNode = ReferenceMap.getCallOrNewNodeForTarget(n);
          if (NodeUtil.isExpressionResultUsed(callNode)) {
            // At least one call site uses the return value, this
            // is not a candidate.
            return false;
          }
          seenUse = true;
        } else if (isCandidateDefinition(n)) {
          // NOTE: While is is possible to optimize calls to functions for which we know
          // only some of the definition are candidates but to keep things simple, only
          // optimize if all of the definitions are known.
          seenCandidateDefiniton = true;
        } else {
          // If this isn't an non-aliasing reference (typeof, instanceof, etc)
          // then there is nothing that can be done.
          if (!OptimizeCalls.isAllowedReference(n)) {
            return false;
          }
        }
      }
  
      return seenUse && seenCandidateDefiniton;
    }
docs: This reference set is a candidate for return-value-removal if:
  - if the all call sites are known (not aliased, not exported)
  - if all call sites do not use the return value
  - if there is at least one known function definition
  - if there is at least one use
  NOTE: unknown definitions are allowed, as only known
  definitions will be removed.