You don't need to save the element that you are going to remove. Also you can chain as many selectors as you want (see: http://www.w3schools.com/jquery/jquery_chaining.asp). Another thing is going up 10 levels in a tree is a bad idea. If the tree changes in one level you are removing things you don't want. It's better to assign a id / class and remove by it.