/**
 * Given a nested dictionary, flatten it into a single dictionary with keys as the concatenation of all nested keys.
 */
fun flattenDictionary(nestedDict: Map<String, Any>): Map<String, Any> {

    val flattenedDict = mutableMapOf<String, Any>()
    for ((key, value) in nestedDict) {
        if (value is Map<*, *>) {
            val flattenValue = flattenDictionary(value as Map<String, Any>)
            for ((subKey, subValue) in flattenValue) {
                val newKey = if (key.isNotEmpty()) "$key.$subKey" else subKey
                flattenedDict[newKey] = subValue
            }
        } else {
            flattenedDict[key] = value
        }
    }
    return flattenedDict
}
/**
 * Given a nested dictionary, flatten it into a single dictionary with keys as the concatenation of all nested keys.
 */
fun flattenDictionary(nestedDict: Map<String, Any>): Map<String, Any> {
/**
 * Given a nested dictionary, flatten it into a single dictionary with keys as the concatenation of all nested keys.
 */
fun flattenDictionary(nestedDict: Map<String, Any>): Map<String, Any> {

    val flattenedDict = mutableMapOf<String, Any>()
    for ((key, value) in nestedDict) {
        if (value is Map<*, *>) {
            val flattenValue = flattenDictionary(value as Map<String, Any>)
            for ((subKey, subValue) in flattenValue) {
                val newKey = if (key.isNotEmpty()) "$key.$subKey" else subKey
                flattenedDict[newKey] = subValue
            }
        } else {
            flattenedDict[key] = value
        }
    }
    return flattenedDict
}