def walk_leaf_dirs(root_dir):
    """Yield the paths of the leaf directories under root_dir.

    Leaf directories are those dirs that don't have any subdirectories.
    """
    import os
    for base_dir, dirs, filenames in os.walk(root_dir):
        if len(dirs) == 0:
            yield base_dir
