private static <T extends IJsonConfigurable<T>> JsonNode createJsonNode(final IJsonConfigurable<T> expression) {
        if (expression == null) {
            return null;
        }
        final ObjectMapper mapper = JsonUtils.mapper;

        final ObjectNode node = mapper.createObjectNode();
        node.set(FIELD_TYPE, new TextNode(expression.getId()));
        final JsonNode config = expression.getJsonConfig();
        if (config != null) {
            node.set(FIELD_CONFIG, config);
        }
        final List<T> children = expression.getChildren();
        if (children != null && !children.isEmpty()) {
            final ArrayNode array = mapper.createArrayNode();
            for (IJsonConfigurable<?> child : children) {
                final JsonNode childNode = createJsonNode(child);
                if (childNode != null) {
                    array.add(childNode);
                }
            }
            if (!array.isEmpty()) {
                node.set(FIELD_CHILDREN, array);
            }
        }
        return node;
    }
Helper method to implement HashCode for an object implementing IJsonConfiguration
main/src/main/java/cgeo/geocaching/utils/config/JsonConfigurationUtils.java