Using the pathlib library in Python 3 this is a one-liner (other than includes). In the snippet below target_path is a string of the root of the tree you want to clean up:
from pathlib import Path
import os
[os.removedirs(p) for p in Path(target_path).glob('**/*') if p.is_dir() and len(list(p.iterdir())) == 0]
To make it a little less dense and easier to follow, this is the same thing written without the list comprehension
for p in Path(target_path).glob('**/*'):
if p.is_dir() and len(list(p.iterdir())) == 0:
os.removedirs(p)
The interesting feature here is the if statement filters for empty directories that are leaves on the filesystem tree. os.removedirs() deletes all empty folders in above an empty leaf. If there are several empty leaves on a branch, deleting the last empty leaf will cause os.removedirs() to walk up the branch. So all empty dirs are gone in a single iteration of the loop with no recursion necessary!