recursive implementation of rbtree