bugfix memory leak
added function is<Type>() to check if a Tree can be cast to a type