Implement remove function for trees