In a similar fashion, the compiler detects patterns which will never match the input value:
switch (Leaf("foo")) { case Leaf(_) | Leaf("foo"): // This pattern is unused case Node(l,r): case _: // This pattern is unused }