Collects the visited nodes of type T into a collection, as long as they satisfy a condition.
an ordered list (DFS order) containing all the visited nodes of type T in the tree
condition to be satisfied for the node to be collected
node type