The idea is to iterate over all elements recursively and count down the parents:
from bs4 import BeautifulSoup
from urllib2 import urlopen
data = """your html goes here"""
depth = 5
soup = BeautifulSoup(data)
for tag in soup.find_all():
if len(list(tag.parents)) == depth:
tag.extract()
print soup.prettify()
prints:
<html>
<head>
<title>
</title>
<meta/>
<meta/>
<link/>
</head>
<body>
<div>
<div></div>
<span></span>
</div>
</body>
</html>