code: private void ensureIndex(DS session, EntityTypeMetadata<NodeMetadata<L>> entityTypeMetadata,
              IndexedPropertyMethodMetadata<IndexedPropertyMetadata> indexedProperty) {
          if (indexedProperty != null) {
              IndexedPropertyMetadata datastoreMetadata = indexedProperty.getDatastoreMetadata();
              if (datastoreMetadata.isCreate()) {
                  L label = entityTypeMetadata.getDatastoreMetadata().getDiscriminator();
                  PrimitivePropertyMethodMetadata<PropertyMetadata> propertyMethodMetadata = indexedProperty.getPropertyMethodMetadata();
                  if (label != null && propertyMethodMetadata != null) {
                      ensureIndex(session, label, propertyMethodMetadata, datastoreMetadata.isUnique());
                  }
              }
          }
      }
docs: Ensures that an index exists for the given entity and property.
  
  @param entityTypeMetadata
  The entity.
  @param indexedProperty
  The index metadata.