private <T extends DomainObject> boolean mergeMergeableBackgroundCommands(
			BackgroundCommand<T> newCommand, PriorityQueue<BackgroundCommand<?>> queue) {
		@SuppressWarnings("unchecked")
		BackgroundCommand<T> lastCommand = (BackgroundCommand<T>) queue.getLast();
		if (!(lastCommand instanceof MergeableBackgroundCommand) ||
			!(newCommand instanceof MergeableBackgroundCommand)) {
			return false;
		}

		// merge the two into the original command, as it is still in the queue in the correct
		// place
		MergeableBackgroundCommand<T> mergeableBackgroundCommand =
			(MergeableBackgroundCommand<T>) lastCommand;
		MergeableBackgroundCommand<T> newMergeableBackgroundCommand =
			(MergeableBackgroundCommand<T>) newCommand;
		mergeableBackgroundCommand.mergeCommands(newMergeableBackgroundCommand);
		return true;
	}
Schedule the given background command when the current command completes.

@param cmd background command to be scheduled
@param obj domain object that supports undo/redo
Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/mgr/ToolTaskManager.java