Climbing the label tree: Hierarchy-preserving contrastive learning for medical imaging