How the second key stands to the first, or null when they are not related.
The relations are tested in a fixed order — identity, enharmonic spelling,
then the six closely related keys in the order relatedKeysOf lists
them — and the first match is reported. Only the identity test looks at the
tonic spelling; every other test compares root pitch class and mode, so
C# minor and Db minor both read as the relative of E major.
Both keys are read through the mode their third names, exactly as
relatedKeysOf reads the key it is given, so A harmonic minor stands
to C major as A minor does whichever of the two is asked about. That is what
makes the answer symmetric: if one key's related keys name the other, the
relation between them is reported from either side.
How the second key stands to the first, or null when they are not related.
The relations are tested in a fixed order — identity, enharmonic spelling, then the six closely related keys in the order relatedKeysOf lists them — and the first match is reported. Only the identity test looks at the tonic spelling; every other test compares root pitch class and mode, so C# minor and Db minor both read as the relative of E major.
Both keys are read through the mode their third names, exactly as relatedKeysOf reads the key it is given, so A harmonic minor stands to C major as A minor does whichever of the two is asked about. That is what makes the answer symmetric: if one key's related keys name the other, the relation between them is reported from either side.