# some lines below use to generate false error messages class Node where T must be IComparable var _left as Node? var _right as Node? var _item as T cue init base.init cue init(item as T) .init(item, nil, nil) cue init(item as T, left as Node?, right as Node?) base.init _item = item _left = left _right = right pro left from var pro right from var get item from var def compareTo(node as Node) as int # this method enables comparison operators in Cobra like "a < b" where a and b are Nodes return .item.compareTo(node.item) class BinaryTree where T must be IComparable var _root as Node cue init(root as Node) base.init _root = root pro root from var def add(items as vari T) for item in items .add(item) def add(item as T) _add(Node(item), _root) def _add(newNode as Node, root as Node) if newNode > root right = root.right if right _add(newNode, right) # passing the second argument used to cause a false error message else root.right = newNode # used to cause a false error message else if newNode > root left = root.left if left _add(newNode, left) # passing the second argument used to cause a false error message else root.left = newNode # used to cause a false error message class Program def main is shared pass