first variation that appears to be working rb tree
full working rb tree