countReferences() {
    const counts = {};
    const visitReference = (reference) => {
      if (counts[reference]) {
        counts[reference]++;
      } else {
        counts[reference] = 1;
        visitValue(this.values[reference]);
      }
    };
    const visitValue = (value) => {
      if (value.arrayValue != null) {
        value.arrayValue.values.forEach(visitValue);
      } else if (value.dictionaryValue != null) {
        Object.values(value.dictionaryValue.values).forEach(visitValue);
      } else if (value.functionDefinitionValue != null) {
        visitReference(value.functionDefinitionValue.body);
      } else if (value.functionInvocationValue != null) {
        const inv = value.functionInvocationValue;
        if (inv.functionReference != null) {
          visitReference(inv.functionReference);
        }
        Object.values(inv.arguments).forEach(visitValue);
      } else if (value.valueReference != null) {
        visitReference(value.valueReference);
      }
    };
    visitReference(this.rootReference);
    return counts;
  }
@return {!Object<string,number>} counts for each reference in the tree.