Value For Dict - Python : I have a code to get a specific value from yahoo API. The problem is it matched the IF statement but it returns None and also again its going to the else loop for some reason. Can some one help me out pls. Very new to python.

I want to get the value of key astronomy as return and simple help to correct the give code will help me to move further.
------------------------------------------------------------------------

import requests
def walk(d = None,val = None):

    if val == 'astronomy':
        return (val,d)
    
    else:
        
        for k,v in d.items():
            if isinstance(v,dict):
                p = d[k]
                walk(d=p,val=k)
            
r = requests.get('https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22nome%2C%20ak%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys',stream = True)

n = r.json()
b = walk(d=n)
print(b)
---------------------------------------------

Thanks