I designed two units, one carrying an Ice Staff and the other carrying an Incineration Staff. Here's the upgrade XML for the first:
<EquipmentUpgradeDef>
<SelectionCriterion>MaximizeBest</SelectionCriterion>
<ComparisonAttribute>UnitStat_Attack_Cold</ComparisonAttribute>
<ComparisonAttribute>UnitStat_Attack_Fire</ComparisonAttribute>
<ComparisonAttribute>UnitStat_Attack_Lightning</ComparisonAttribute>
<ComparisonAttribute>UnitStat_Attack_Poison</ComparisonAttribute>
<WeaponUpgradeType>ColdStaff</WeaponUpgradeType>
<EquipmentSlot>Weapon</EquipmentSlot>
<EquipmentSlot>Defense</EquipmentSlot>
<ForUpgradeActionOnly>0</ForUpgradeActionOnly>
</EquipmentUpgradeDef>
and here's the XML for the second:
<EquipmentUpgradeDef>
<SelectionCriterion>MaximizeBest</SelectionCriterion>
<ComparisonAttribute>UnitStat_Attack_Cold</ComparisonAttribute>
<ComparisonAttribute>UnitStat_Attack_Fire</ComparisonAttribute>
<ComparisonAttribute>UnitStat_Attack_Lightning</ComparisonAttribute>
<ComparisonAttribute>UnitStat_Attack_Poison</ComparisonAttribute>
<WeaponUpgradeType>FireStaff</WeaponUpgradeType>
<EquipmentSlot>Weapon</EquipmentSlot>
<EquipmentSlot>Defense</EquipmentSlot>
<ForUpgradeActionOnly>0</ForUpgradeActionOnly>
</EquipmentUpgradeDef>
Having now researched the appropriate tech, the first unit now upgrades from the Ice Staff to the Hailstone Staff (expected), while the second upgrades from the Incineration Staff to the Leht Staff instead of to the Hellfire Staff (not expected). I'm guessing that this is because both the Leht Staff and the Hellfire staff are classified as FireStaff, despite the Leht Staff doing lightning damage rather than fire.
And, indeed, the Leht Staff is listed as an Enchanted Fire Staff in the unit design window:

If units that are vulnerable to fire damage (ice elementals, for example) are also vulnerable to lightning damage, then this is not a problem and I should stop thinking about it. Otherwise, the inability to upgrade to a HellFire Staff could present a reason not to upgrade and to design and train a new unit type instead.