Looking for a key in a nested dict

Wouldn’t this be a classic case of recursion? This code can be easily modified to push multiple positive results to an array.

function retrieve(dict, key_of_interest)
        for (key, value) in dict
        if key == key_of_interest
        	return value
        end
        if value isa Dict
            return  retrieve(value, key_of_interest)
        end
    end
end
3 Likes