private static boolean visitTerminal(final SchemaVisitor visitor, final Schema schema, final Deque<Object> dq) {
    SchemaVisitorAction action = visitor.visitTerminal(schema);
    switch (action) {
    case CONTINUE:
      break;
    case SKIP_SUBTREE:
      throw new UnsupportedOperationException("Invalid action " + action + " for " + schema);
    case SKIP_SIBLINGS:
      while (!dq.isEmpty() && dq.getLast() instanceof Schema) {
        dq.removeLast();
      }
      break;
    case TERMINATE:
      return true;
    default:
      throw new UnsupportedOperationException("Invalid action " + action + " for " + schema);
    }
    return false;
  }
@Test
  void cloningError1() {
    assertThrows(IllegalStateException.class, () -> {
      // Visit Terminal with union
      Schema recordSchema = new Schema.Parser().parse(
          "{\"type\": \"record\", \"name\": \"R\", \"fields\":[{\"name\": \"f1\", \"type\": [\"int\", \"long\"]}]}");
      new CloningVisitor(recordSchema).visitTerminal(recordSchema.getField("f1").schema());
    });
  }