I was able to get variable importance using iris data in R, using below code
But when I tried the same with other data I have. tree$variable.importance returns NULL. Any specific reason for that. I was getting NaN for variable importance using "rf" method in caret. varImp() was used.