void insertNode(int r) {
			int i, p, cmp;

			cmp = 1;
			p = N + 1 + unsigned(textBuf.get(r));
			rchild[r] = lchild[r] = NIL;
			matchLength = 0;
			for (;;) { // Enter the walrus
				if (cmp >= 0) {
					if (rchild[p] != NIL) {
						p = rchild[p];
					}
					else {
						rchild[p] = r;
						parent[r] = p;
						return;
					}
				}
				else {
					if (lchild[p] != NIL) {
						p = lchild[p];
					}
					else {
						lchild[p] = r;
						parent[r] = p;
						return;
					}
				}
				for (i = 1; i < F; i++) {
					if ((cmp = unsigned(textBuf.get(r + i)) - unsigned(textBuf.get(p + i))) != 0) {
						break;
					}
				}
				if (i > matchLength) {
					matchPosition = p;
					if ((matchLength = i) >= F) {
						break;
					}
				}
			}
			parent[r] = parent[p];
			lchild[r] = lchild[p];
			rchild[r] = rchild[p];
			parent[lchild[p]] = r;
			parent[rchild[p]] = r;
			if (rchild[parent[p]] == p) {
				rchild[parent[p]] = r;
			}
			else {
				lchild[parent[p]] = r;
			}
			parent[p] = NIL; /* remove p */
		}
initialize state, mostly the trees

For i = 0 to N - 1, rchild[i] and lchild[i] will be the right and
left children of node i. These nodes need not be initialized. Also
parent[i] is the parent of node i. These are initialzied to NIL (=N),
which stands for 'not used.' For i = 0 to 256, rchild[N + i + 1] is
the root of the tree for strings that begin with character i. These
are initialized to NIL. Note there are 256 trees.
Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/lzss/LzssCodec.java