private void renderHierarchy(Hierarchy<T> hierarchy, int level, String path) {
		Map<Key, Hierarchy<T>> dimension = hierarchy.getChildren();
		Key[] keys = dimension.keySet().toArray(new Key[dimension.size()]);
		Arrays.sort(keys, comparator);

		int colspan;
		
		int index = 0;

		String parentId = null;
		
		for (Key key : keys) {
			append("<td ");

			boolean lastChild = dimension.get(key).getChildren().size() == 0;
			
			index = appendCssClass(
					path, index, 
					lastChild ? "c-ne" : null,
					dimension.get(key).getDimensionValue() instanceof Number ? "c-n" : null);

			if (lastChild) {
				//	XXX for now this is the only string concatenation, remove this in future releases
				parentId = path + "-" + index;
				append(" id='i", parentId, '\'');
			}
			
			int rowspan = dimension.get(key).getSizeWithTotals() - 1;
			if (rowspan > 1) {
			    append(" rowspan='", rowspan, "'");
			}
			append(">");
			append(dimension.get(key).getDimensionValue());
			append("</td>");
			if (lastChild) {
				append("</tr>");
				colspan = dimensions.length - (level + 1);
				append("\n<tr><td ");
				index = appendCssClass(path, index, "c-t");
				if (colspan > 1) {
				    append(" colspan='", colspan, "'");
				}
				append(">Totals:</td>");
				index = renderTotals(0, dimension.get(key).getTotals(), path, index, false, parentId);
				append("</tr>");
				append("\n<tr>");
			} else {
				renderHierarchy(dimension.get(key), level + 1, path + "-" + index);
			}
		}
		
		int offsetFromEnd;
		
		if (keys.length == 0) {
			append("</tr>");
			offsetFromEnd = 0;
		} else {
			offsetFromEnd = "</tr>".length();
		}
		
		insert(offsetFromEnd, "\n<tr><td ");
		index = insertCssClass(offsetFromEnd, path, index, 
				true /* set this to true to make totals collapsed only with parent dimension */,
				true,
				"c-t");
		colspan = dimensions.length - level;
		if (colspan > 1) {
		    insert(offsetFromEnd, " colspan='", colspan, "'");
		}
		insert(offsetFromEnd, ">Totals:</td></tr>");
		index = renderTotals(offsetFromEnd + "\n<tr>".length(), hierarchy.getTotals(), path, index, 
				true /* set this to true to make totals collapsed only with parent dimension */,
				path);
	}