void recursiveSort(boolean sortLeaves) {
		if (isLeaf && !sortLeaves)
			return;
		boolean change = false;
		// Use modified bubble sort for almost-sorted lists.
		do {
			change = false;
			for (int i = 0; i < contents.size() - 1; i++)
				change |= swap(i);
			if (!change)
				break;
			change = false;
			for (int i = contents.size() - 2; i >= 0; i--)
				change |= swap(i);
		} while (change);
		for (int i = 0; i < contents.size(); i++) {
			Object o = contents.get(i);
			if (o instanceof NestingTree)
				((NestingTree) o).recursiveSort(sortLeaves);
		}
	}