Added walk_leafs function