Use os.walk instead of get_leaf_nodes.