first
and second
, to None
. These will be used to track the two nodes that need to be swapped.pred
(predecessor) to None
to keep track of the previous node in the inorder traversal.None
.None
, set it to the current node and move to the left child of the current node.None
and check if the current node is out of order with the pred
node. If it is, update first
and second
.first
and second
.