public Sketch<?> merge(Sketch<?> left, Sketch<?> right) {
        if (left instanceof NormalSketch && right instanceof NormalSketch) {
            return mergeNormalWithNormal(asNormal(left), asNormal(right));
        } else if (left instanceof NormalSketch && right instanceof SparseSketch) {
            return mergeNormalWithSparse(asNormal(left), asSparse(right));
        } else if (left instanceof SparseSketch && right instanceof NormalSketch) {
            return mergeNormalWithSparse(asNormal(right), asSparse(left));
        } else if (left instanceof SparseSketch && right instanceof SparseSketch) {
            return mergeSparseWithSparse(asSparse(left), asSparse(right));
        } else {
            throw new IllegalArgumentException(
                    String.format("Invalid sketch types: left=%s, right=%s", right.getClass(), left.getClass()));
        }
    }
@Test
    public void requireThatMergingNormalAndSparseSketchReturnsNormalSketch() {
        SparseSketch s1 = SketchUtils.createSparseSketch(1);
        NormalSketch s2 = SketchUtils.createNormalSketch(2);

        Sketch<?> result = merger.merge(s1, s2);
        assertEquals(result.getClass(), NormalSketch.class);
        assertTrue("Should return the NormalSketch instance given by the arguments.", result == s2);
        SketchUtils.assertSketchContains(result, 1, 2);
    }