private int getAbsoluteInsertionIndex(Row parent, int childInsertIndex) {
		int insertAt;
		int count;

		if (parent == null) {
			count = mModel.getRowCount();
			insertAt = childInsertIndex;
			while (insertAt < count && mModel.getRowAtIndex(insertAt).getParent() != null) {
				insertAt++;
			}
		} else {
			int i = parent.getChildCount();

			if (i == 0 || !parent.isOpen()) {
				insertAt = mModel.getIndexOfRow(parent) + 1;
			} else if (childInsertIndex < i) {
				insertAt = mModel.getIndexOfRow(parent.getChild(childInsertIndex));
			} else {
				Row row = parent.getChild(i - 1);

				count = mModel.getRowCount();
				insertAt = mModel.getIndexOfRow(row) + 1;
				while (insertAt < count && mModel.getRowAtIndex(insertAt).isDescendantOf(row)) {
					insertAt++;
				}
			}
		}
		return insertAt;
	}