Case tree building considers heterogeneous types

Previously, arguments with different types in each cases could have led
to run-time failure (or non-reduction at compile-time) since branching
takes only the constructor tag into account. Now the case tree compiler
orders the patterns so that this can no longer happen.

Fixes #1080
Fixes #771