Binary tree garbage collecting implementation