You have to code that yourself. Here's a rather inefficient, but working version I've quickly hacked together:
var whole_dictionary = # ...
# you cannot use this symbol in your dictionary keys any longer!
const SPLIT_SYMBOL = "/"
replace_value(whole_dictionary, "key2", "new_value")
func replace_value(dict, key, new_value):
var hits = search_for(whole_dictionary, key)
if hits.size() == 1:
var path = hits.split(SPLIT_SYMBOL)
var temp = dict
for key in path:
if temp[key] is Dictionary:
temp = temp[key]
temp[key] = new_value
func search_for(dict, query):
var hits = 
for key in dict.keys():
if dict[key] is Dictionary:
var ret = search_for(dict[key], query)
for subkey in ret:
hits.append(key + SPLIT_SYMBOL + subkey)
elif key == query:
Though the real question here is: What are you trying to do that requires replacing a certain value in a (apparently very deeply) nested dictionary if and only if the key this value is stored under is completely unique for that mega-dictionary?
I'm having a hard time picturing a situation where one would need this.