refactor: share the lookup loop of `DiscrTree.getMatch` and `Sym.getMatch` (#16469)

This PR replaces the two copies of the discrimination tree lookup loop
in `DiscrTree.getMatch` and `Sym.getMatch` by one loop,
`DiscrTree.Trie.getMatchLoop`, parametrized over computing the key of a
subterm and pushing its arguments.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
3 files changed