building trees for categorical variables