src/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/concat23Trees.ts/concat23TreesOfSameHeight
export function concat23TreesOfSameHeight(items: AstNode[], createImmutableLists: boolean = false): AstNode | null {
	if (items.length === 0) {
		return null;
	}
	if (items.length === 1) {
		return items[0];
	}

	let length = items.length;
	// All trees have same height, just create parent nodes.
	while (length > 3) {
		const newLength = length >> 1;
		for (let i = 0; i < newLength; i++) {
			const j = i << 1;
			items[i] = ListAstNode.create23(items[j], items[j + 1], j + 3 === length ? items[j + 2] : null, createImmutableLists);
		}
		length = newLength;
	}
	return ListAstNode.create23(items[0], items[1], length >= 3 ? items[2] : null, createImmutableLists);
}