public static boolean equalTo(Inspector a, Inspector b) {
        if (a.type() != b.type()) return false;

        switch (a.type()) {
            case NIX: return a.valid() == b.valid();
            case BOOL: return a.asBool() == b.asBool();
            case LONG: return a.asLong() == b.asLong();
            case DOUBLE: return Double.compare(a.asDouble(), b.asDouble()) == 0;
            case STRING: return a.asString().equals(b.asString());
            case DATA: return Arrays.equals(a.asData(), b.asData());
            case ARRAY: {
                if (a.entries() != b.entries()) return false;
                for (int i = 0; i < a.entries(); i++) {
                    if (!equalTo(a.entry(i), b.entry(i))) return false;
                }
                return true;
            }
            case OBJECT: {
                if (a.fields() != b.fields()) return false;
                boolean[] equal = new boolean[]{ true };
                a.traverse((String key, Inspector value) -> {
                    if (equal[0] && !equalTo(value, b.field(key))) equal[0] = false;
                });
                return equal[0];
            }
            default: throw new IllegalStateException("Unexpected type: " + a.type());
        }
    }
@Test
    public void verifyArrayEquality() {
        Slime slimeLeft = new Slime();
        Cursor left = slimeLeft.setArray();
        left.addArray().addString("a");
        left.addArray().addString("b");

        Slime slimeRight = new Slime();
        Cursor right = slimeRight.setArray();
        right.addArray().addString("a");
        right.addArray().addString("b");

        assertTrue(left.equalTo(right));
        assertTrue(right.equalTo(left));
        assertTrue(left.equalTo(left));

        right.addArray().addString("c");
        assertFalse(left.equalTo(right));
        assertFalse(right.equalTo(left));

        // Order matters
        Slime slimeRight2 = new Slime();
        Cursor right2 = slimeRight2.setObject();
        right2.addArray().addString("b");
        right2.addArray().addString("a");
        assertFalse(left.equalTo(right2));
        assertFalse(right2.equalTo(left));
    }