public static void allocateHuffmanCodeLengths (final int[] array, final int maximumLength) {

		switch (array.length) {
			case 2:
				array[1] = 1;
			case 1:
				array[0] = 1;
				return;
		}

		/* Pass 1 : Set extended parent pointers */
		setExtendedParentPointers (array);

		/* Pass 2 : Find number of nodes to relocate in order to achieve maximum code length */
		int nodesToRelocate = findNodesToRelocate (array, maximumLength);

		/* Pass 3 : Generate code lengths */
		if ((array[0] % array.length) >= nodesToRelocate) {
			allocateNodeLengths (array);
		} else {
			int insertDepth = maximumLength - (32 - Integer.numberOfLeadingZeros (nodesToRelocate - 1));
			allocateNodeLengthsWithRelocation (array, nodesToRelocate, insertDepth);
		}

	}