private static Object[] getContiguousIndexBlocks (TreeModelEvent e, boolean reverseOrder) {
        int[] indices = e.getChildIndices();
        
        //Quick check if there's only one index
        if (indices.length == 1) {
            return new Object[] {indices};
        }
        
       ArrayList<ArrayList<Integer>> al = new ArrayList<ArrayList<Integer>>();
        
        //Sort the indices as requested
        if (reverseOrder) {
            inverseSort (indices);
        } else {
            Arrays.sort (indices);
        }


        //The starting block
        ArrayList<Integer> currBlock = new ArrayList<Integer>(indices.length / 2);
        al.add(currBlock);
        
        //The value we'll check against the previous one to detect the
        //end of contiguous segment
        int lastVal = -1;
        
        //Iterate the indices
        for (int i=0; i < indices.length; i++) {
            if (i != 0) {
                //See if we've hit a discontinuity
                boolean newBlock = reverseOrder ? indices[i] != lastVal - 1 :
                    indices[i] != lastVal + 1;
                    
                if (newBlock) {
                    currBlock = new ArrayList<Integer>(indices.length - 1);
                    al.add(currBlock);
                }
            }
            currBlock.add (new Integer(indices[i]));
            lastVal = indices[i];
        }
        
        ArrayList<int[]> res = new ArrayList<int[]>(al.size());
        for (int i=0; i < al.size(); i++) {
            ArrayList<Integer> curr = al.get(i);
            Integer[] ints = curr.toArray (new Integer[0]);
            
            res.add(toArrayOfInt(ints));
        }
        
        return res.toArray();
    }