reimplement binary search trees with functors