Added filteredTree()

Modified with Jan's improvements.