The node you are looking for is at Scheme - Transposing pitches with minimum accidentals (“smart” transpose).