`Arrays.deepEquals` can replace this whole loop.