private static <T> ListNodeSTL<T> merge(ListNodeSTL<T> a, ListNodeSTL<T> b, Comparator<T> comparator, ListNodeSTL<T> TERMINAL) {
		ListNodeSTL<T> head = new ListNodeSTL<>();
		ListNodeSTL<T> c = head;
		do {
			if (b == TERMINAL || ((a != TERMINAL) && comparator.compare(a.value, b.value)<= 0)) {
				c.next = a;
				c = a;
				a = a.next;
			}
			else {
				c.next = b;
				c = b;
				b = b.next;
			}
		}
		while(c != TERMINAL);
		return head.next;
	}
moves a single element, decreasing the length of list by 1 and increasing this list by 1.
@param position the position into this list where the element is to be inserted
@param list the list from which the element is removed.
@param listPosition the postion of the element to be removed.
Ghidra/Framework/Generic/src/main/java/generic/stl/ListSTL.java