mrg rts1@(rt1 : rts1') rts2@(rt2 : rts2')
  | rank rt1 < rank rt2 = rt1 : (mrg rts1' rts2)
  | rank rt2 < rank rt1 = rt2 : (mrg rts1 rts2')
  | otherwise = insTree (link rt1 rt2) (mrg rts1' rts2')
mrg rts1@(rt1 : rts1') rts2@(rt2 : rts2')
  | rank rt1 < rank rt2 = rt1 : (mrg rts1' rts2)
  | rank rt2 < rank rt1 = rt2 : (mrg rts1 rts2')
  | otherwise = insTree (link rt1 rt2) (mrg rts1' rts2')
mrg rts1@(rt1 : rts1') rts2@(rt2 : rts2')
  | rank rt1 < rank rt2 = rt1 : (mrg rts1' rts2)
  | rank rt2 < rank rt1 = rt2 : (mrg rts1 rts2')
  | otherwise = insTree (link rt1 rt2) (mrg rts1' rts2')