rbtree move logic into src/rbtree.c