Iterators and Generators: Difficult Solutions

code writing

Write a generator function that goes through a tree and yields all of the values in the tree.
def tree_gen(t):
    if t.is_leaf():
        yield t.label()
    else:
        for branch in t.branches():
        yield from tree_gen(branch)

Write a generator function that yields the elements in a list in order from greatest to least. You can assume there is at least one element in the list, and that all elements are unique.
def sort_list_gen(lst):
>>> lst = [8, 1, 5, 7]
>>> gen = sort_list_gen(lst)
>>> list(gen)
8
7
5
1
    while len(lst) > 0:
        yield max(lst)
        lst.remove(max(lst))