public static int[] eliminateRedundantLinks(int[] links) {
        //
        final int tag = Integer.MIN_VALUE;
        //
        int last = 0;
        int ctr = 0;
        //
        if (links.length > 0) {
            ctr += LINK_SIZE;
        }
        //
        // first make redundant links invalid.
        //
        for (int i = LINK_SIZE; i < links.length; i += LINK_SIZE) {
            if (equal(links, i, last)) {
                //
                // links equal, eliminate link.
                //
                links[i] = tag;
            } else {
                last = i;
                ctr += LINK_SIZE;
            }
        }
        //
        // collect non-null links
        //
        int[] result = new int[ctr];
        int idx = 0;
        for (int i = 0; i < links.length; i += LINK_SIZE) {
            if (links[i] != tag) {
                copy(links, i, result, idx);
                idx += LINK_SIZE;
            }
        }
        return result;
    }