creating balanced trees