added an insert method for tree