Add helper function verify_material

Allows to remove a lot of assert code in endgames.

No functional change.