def remove_empty_dirs(path):
    """ removes empty dirs under a given path """
    for root, dirs, files in os.walk(path):
        for d in dirs:
            dir_path = os.path.join(root, d)
            if not os.listdir(dir_path):
                os.rmdir(dir_path)
removes empty dirs under a given path