Overloaded the function that assigns types to the nodes of a tree