addToIndex_(featureKey, feature) {
    let valid = true;
    if (feature.getId() !== undefined) {
      const id = String(feature.getId());
      if (!(id in this.idIndex_)) {
        this.idIndex_[id] = feature;
      } else if (feature instanceof RenderFeature) {
        const indexedFeature = this.idIndex_[id];
        if (!(indexedFeature instanceof RenderFeature)) {
          valid = false;
        } else if (!Array.isArray(indexedFeature)) {
          this.idIndex_[id] = [indexedFeature, feature];
        } else {
          indexedFeature.push(feature);
        }
      } else {
        valid = false;
      }
    }
    if (valid) {
      assert(
        !(featureKey in this.uidIndex_),
        'The passed `feature` was already added to the source',
      );
      this.uidIndex_[featureKey] = feature;
    }
    return valid;
  }
@param {string} featureKey Unique identifier for the feature.
@param {FeatureType} feature The feature.
@return {boolean} The feature is "valid", in the sense that it is also a
    candidate for insertion into the Rtree.
@private