private void removeIndices(JsonNode node, boolean remove) {
        if (!node.isObject() && !node.isArray()) {
            return;
        }
        boolean isArray = node.isArray();
        if (!isArray) {
            if (remove) {
                ObjectNode objectNode = (ObjectNode) node;
                objectNode.remove("index");
            }
        }

        for (var child : node) {
            removeIndices(child, isArray);
        }
    }
The utility merges chunks received from a streaming response. The original reference implementation is provided
<a href="https://github.com/epam/ai-dial-sdk/blob/0.10.1/aidial_sdk/utils/merge_chunks.py">here</a>.
server/src/main/java/com/epam/aidial/core/server/util/MergeChunks.java