Refactor 'swap nodes in pairs'.