<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def walk_tree(start, attr):
 """ Recursively walk through a tree relationship. This iterates a tree in a top-down approach, fully reaching the end of a lineage before moving onto the next sibling of that generation. """

    path = [start]
    for child in path:
        yield child
        idx = path.index(child)
        for grandchild in reversed(getattr(child, attr)):
            path.insert(idx + 1, grandchild)