Added filteredTree()

Modified using Jan's improvements.