def top_down(brule, fns=basic_fns):
 return chain(do_one(brule, identity), (lambda expr: sall(top_down(brule, fns), fns)(expr)))

def top_down ( brule , fns = basic_fns ) : return chain ( do_one ( brule , identity ) , ( lambda expr : sall ( top_down ( brule , fns ) , fns ) ( expr ) ) )
apply a rule down a tree running it on the top nodes first .