private static Variable[] gatherMergeSet(Function function, Variable seed) {
		TreeMap<String, Variable> nameMap = new TreeMap<>();
		for (Variable var : function.getAllVariables()) {
			nameMap.put(var.getName(), var);
		}
		String baseName = seed.getName();
		int pos = baseName.lastIndexOf('$');
		if (pos >= 0) {
			baseName = baseName.substring(0, pos);
		}
		DataType dataType = seed.getDataType();
		Variable currentVar = nameMap.get(baseName);
		int index = 0;
		boolean sawSeed = false;
		ArrayList<Variable> mergeArray = new ArrayList<>();
		for (;;) {
			if (currentVar == null) {
				break;
			}
			if (!currentVar.getDataType().equals(dataType)) {
				break;
			}
			if (index != 0 && currentVar instanceof Parameter) {
				break;
			}
			if (index != 0 && currentVar.hasStackStorage()) {
				break;
			}
			if (currentVar == seed) {
				sawSeed = true;
			}
			mergeArray.add(currentVar);
			index += 1;
			String newName = baseName + '$' + Integer.toString(index);
			currentVar = nameMap.get(newName);
		}
		Variable[] res;
		if (!sawSeed) {
			res = new Variable[1];
			res[0] = seed;
		}
		else {
			res = new Variable[mergeArray.size()];
			mergeArray.toArray(res);
		}
		return res;
	}
Given a particular seed Variable, find the set of local Variables that are intended to be
merged containing that seed. The result will be an array with at least the seed variable in it.
@param function is the function containing the local variables
@param seed is the seed local variable
@return an array of all Variables intended to be merged.
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighFunctionDBUtil.java