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 convertSuccess() {
        String expectedJson = "{\n"
                + "   \"hazelcast\":{\n"
                + "      \"network\":{\n"
                + "         \"port\":{\n"
                + "            \"auto-increment\":true,\n"
                + "            \"port-count\":100,\n"
                + "            \"port\":5701,\n"
                + "            \"outbound-ports\":[\n"
                + "               \"33000-35000\",\n"
                + "               \"37000,37001,37002,37003\",\n"
                + "               \"38000,38500-38600\"\n"
                + "            ]\n"
                + "         },\n"
                + "         \"public-address\":\"dummy\"\n"
                + "      }\n"
                + "   }\n"
                + "}";
        JSONObject expectedJsonObject = new JSONObject(expectedJson);
        YamlMappingImpl parentNode = createYamlMapping();

        Object converted = YamlToJsonConverter.convert(parentNode);

        assertTrue(expectedJsonObject.similar(converted));
    }