This program trims all the elements matching a given element from a tree:
-- |Trim all the elements matching the given element from this tree. trimTree :: Eq a => a -> Tree a -> Tree a trimTree a (Branch b1 b2) = Branch (trimTree a b1) (trimTree a b2) trimTree a (Leaf x) = if x == a then Empty else Leaf x trimTree _ Empty = Empty
But what if you only wanted to trim exactly one element? What is the problem? (Draw tree)