(/btreeinit)
(/btreeinit returns an initialized binary tree on the operand stack.)
(1 .array)/xdef

(
/binsert)
(/binsert expects a binary tree and a string on the operand stack. It inserts the string into the
binary tree. This routine calls itself recursively.)
(.exch .dup 0 .aget .itype 0 .eq bt1 bt2 /ifelse)/xdef

(bt1)
(bt1 supports /binsert and expects a string and list on the stack.)
( .exch [ .exch 1 .array 1 .array ] 0 .exch .aput)/def

(bt2)
(bt2 supports /binsert and expects a string and list on the stack. the string is compared with
the first element of the list- if it is equal or less then it procedes down the left branch otherwise
it procedes down the right.)
(.aload .pop .aload .pop 4 2 .roll 2 .copy .gt btgt btle /ifelse )/def

(btgt)
(btgt supports bt2 and sets up to recurse down the right tree branch.)
(.pop 3 -1 .roll .pop /binsert)/def

(btle)
(btle supports bt2 and sets up to recurse down the left tree branch.)
(.pop .exch .pop /binsert)/def

(
/bprefixwalk)
(/bprefixwalk expects a binary tree and a procedure on the operand stack. It then delivers the strings
from the tree in prefix order to the provide procedure.)
((!bt!) .exch .def bpwalk)/xdef

(bpwalk)
(bpwalk supports /bprefixwalk and expects a binary tree on the operand stack. This routine calls itself recursively.)
(.dup 0 .aget .itype 0 .eq bwlk1 bwlk2 /ifelse)/xdef

(bwlk1)
(bwlk1 supports bpwalk and returns after popping the nil array)
(.pop) /def

(bwlk2)
(bwlk2 supports bpwalk and procedes to walk the tree. it expects an array on the operand stack.)
(.aload .pop .aload .pop .exch bpwalk .exch !bt! bpwalk)/def

(
/bpostfixwalk)
(/bpostfixwalk expects a binary tree and a procedure on the operand stack. It then delivers the strings
from the tree in postfix order to the provided procedure.)
((!bt!) .exch .def bbwalk)/xdef

(bbwalk)
(bbwalk supports /bpostfixwalk and expects a binary tree on the operand stack. This routine calls itself recursively.)
(.dup 0 .aget .itype 0 .eq bpwlk1 bpwlk2 /ifelse)/xdef

(bpwlk1)
(bpwlk1 supports bbwalk and returns after popping the nil array)
(.pop) /def

(bpwlk2)
(bpwlk2 supports bbwalk and procedes to walk the tree. it expects an array on the operand stack.)
(.aload .pop .aload .pop bbwalk .exch !bt! bbwalk)/def