optimize code of rbtree