lib/rbtree: avoid generating code twice for the cached versions