private void doCreateInternalStructure(DataTypeManager dtm, CategoryPath categoryPath,
			String name, TaskMonitor monitor) throws InvalidDataTypeException, UsrException {

		int length = 0;
		StructureDataType structureDataType =
			new StructureDataType(categoryPath, name, length, dtm);

		// adopt pack setting from current structure
		structureDataType.setPackingEnabled(isPackingEnabled());
		if (getPackingType() == PackingType.EXPLICIT) {
			structureDataType.setExplicitPackingValue(getExplicitPackingValue());
		}

		FieldRange fieldRange = selection.getFieldRange(0);
		int minRow = fieldRange.getStart().getIndex().intValue();
		int maxRow = fieldRange.getEnd().getIndex().intValue();

		// Get data type components to make into structure.
		DataTypeComponent firstDtc = null;
		DataTypeComponent lastDtc = null;
		for (int rowIndex = minRow; rowIndex < maxRow; rowIndex++) {
			DataTypeComponent component = getComponent(rowIndex);
			if (rowIndex == minRow) {
				firstDtc = component;
			}
			if (component == null) {
				lastDtc = component;
				continue;
			}

			DataType dt = component.getDataType();
			int compLength = component.getLength();
			length += compLength;

			if (!structureDataType.isPackingEnabled() && component.isBitFieldComponent()) {
				BitFieldDataType bitfield = (BitFieldDataType) dt;
				structureDataType.insertBitFieldAt(component.getOffset() - firstDtc.getOffset(),
					compLength, bitfield.getBitOffset(), bitfield.getBaseDataType(),
					bitfield.getDeclaredBitSize(), component.getFieldName(),
					component.getComment());
			}
			else {
				structureDataType.add(dt, compLength, component.getFieldName(),
					component.getComment());
			}

			lastDtc = component;
		}

		DataType addedDataType = createDataTypeInOriginalDTM(structureDataType);

		int txId = viewDTM.startTransaction("Replace w/Structure");
		try {
			if (viewComposite.isPackingEnabled()) {
				deleteSelectedComponents();
				insert(minRow, addedDataType, addedDataType.getLength());
			}
			else {
				int adjustmentBytes = 0;
				if (firstDtc != null && firstDtc.isBitFieldComponent() && minRow > 0) {
					DataTypeComponent dtc = getComponent(minRow - 1);
					if (dtc.getEndOffset() == firstDtc.getOffset()) {
						++adjustmentBytes;
					}
				}
				if (lastDtc != null && lastDtc.isBitFieldComponent() &&
					maxRow < getNumComponents()) {
					DataTypeComponent dtc = getComponent(maxRow);
					if (dtc.getOffset() == lastDtc.getEndOffset()) {
						++adjustmentBytes;
					}
				}
				clearSelectedComponents();
				insertMultiple(minRow, DataType.DEFAULT, 1, adjustmentBytes, monitor);
				replace(minRow, addedDataType, addedDataType.getLength());
			}
		}
		finally {
			viewDTM.endTransaction(txId, true);
		}
	}
Get a unique datatype name.  Method based on the logic used by 
{@link DataTypeManager#getUniqueName(CategoryPath, String)} but 
checks both the original and view DTMs for uniqueness.
@param path category path
@param baseName datatype name
@return unique datatype name
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/StructureEditorModel.java