Implement isInTree and removeSmallest