adding type casting when creating a tree

when inserting a node into a tree, adding type casting.