protected static void createOrDescend(JsonObject root, Deque<String> keyPath, String value) {
        // If there are still key-path elements remaining to traverse.
        if (keyPath.size() > 1) {
            // If there's no object already at this key-path create a new JsonObject.
            if (root.getJsonObject(keyPath.peek()) == null) {
                JsonObject newJson = new JsonObject();
                String val = keyPath.pop();
                root.put(val, newJson);
                createOrDescend(newJson, keyPath, value);
            } else { // If there's already an existing object on key-path, grab it and traverse.
                createOrDescend(root.getJsonObject(keyPath.pop()), keyPath, value);
            }
        } else { // Set the value.
            Boolean boolObj = BooleanUtils.toBooleanObject(value);
            if (boolObj != null) {
                root.put(keyPath.pop(), boolObj);
            } else if (StringUtils.isNumeric(value)) {
                root.put(keyPath.pop(), Long.parseLong(value));
            } else {
                root.put(keyPath.pop(), value);
            }
        }
    }
Common OAuth2 base.

@author Marc Savy {@literal <marc@rhymewithgravy.com>}
gateway/engine/vertx-polling/src/main/java/io/apiman/gateway/engine/vertx/polling/fetchers/auth/AbstractOAuth2Base.java