public static Object convert(YamlNode yamlNode) {
        if (yamlNode == null) {
            return JSONObject.NULL;
        }
        if (yamlNode instanceof YamlMapping yamlMapping) {
            JSONObject resultObject = new JSONObject();
            for (YamlNameNodePair pair : yamlMapping.childrenPairs()) {
                resultObject.put(pair.nodeName(), convert(pair.childNode()));
            }
            return resultObject;
        } else if (yamlNode instanceof YamlSequence yamlSequence) {
            JSONArray resultArray = new JSONArray();
            for (YamlNode child : yamlSequence.children()) {
                resultArray.put(convert(child));
            }
            return resultArray;
        } else if (yamlNode instanceof YamlScalar scalar) {
            return scalar.nodeValue();
        }
        throw new IllegalArgumentException("Unknown type " + yamlNode.getClass().getName());
    }
@Test
    public void convertUnknownNode() {
        YamlMappingImpl parentNode = createYamlMapping();
        YamlMappingImpl hazelcast = (YamlMappingImpl) parentNode.childAsMapping("hazelcast");
        YamlNode unknownNode = new YamlNode() {
            @Override
            public YamlNode parent() {
                return hazelcast;
            }

            @Override
            public String nodeName() {
                return "unknown-node";
            }

            @Override
            public String path() {
                return "null";
            }
        };
        hazelcast.addChild("unknown-node", unknownNode);

        Exception exception = assertThrows(IllegalArgumentException.class,
                () -> YamlToJsonConverter.convert(parentNode));
        assertTrue(exception.getMessage().contains("Unknown type "));
    }