private void addToManager(TreePath path,
			Map<DataTypeManager, List<DataType>> managersToDataTypesMap) {
		Object last = path.getLastPathComponent();
		if (last instanceof DataTypeNode) {
			DataTypeNode node = (DataTypeNode) last;
			DataType dataType = node.getDataType();
			DataTypeManager dataTypeManager = dataType.getDataTypeManager();

			List<DataType> dataTypeList = managersToDataTypesMap.get(dataTypeManager);
			if (dataTypeList == null) {
				dataTypeList = new ArrayList<>();
				managersToDataTypesMap.put(dataTypeManager, dataTypeList);
			}

			dataTypeList.add(dataType);
		}
		else if (last instanceof CategoryNode) {
			CategoryNode node = (CategoryNode) last;
			List<GTreeNode> children = node.getChildren();
			for (GTreeNode cnode : children) {
				addToManager(cnode.getTreePath(), managersToDataTypesMap);
			}
		}
	}
Writes the selection out to a file of the user's choosing.  One file will be written for
each DataTypeManager in the selection.
@param gTree The tree that contains the selected nodes.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/ExportToHeaderAction.java