private static Optional<StructuredDataType> convertTargetType(DataType fieldType) {
        return Optional.of(fieldType)
                .filter(NewDocumentReferenceDataType.class::isInstance)
                .map(NewDocumentReferenceDataType.class::cast)
                .map(NewDocumentReferenceDataType::getTargetType);
    }
Converts to the right attribute type from a field datatype
config-model/src/main/java/com/yahoo/schema/document/Attribute.java