1:prev=NIL
2:x=T.root
3:while x=NIL do
4:if prev==x.p then
5:print x.key
6:prev=x
7:if x.left=NIL then
8:x=x.left
9:else if x.right=NIL then
10:x=x.right
11:else
13:end if
14:else if prev==x.left and x.right=NIL then
15:prev=x
16:x=x.right
17:else
18:prev=x
19:x=x.p
20:end if
21:end while