public class SearchTree { private TreeNode root; private TreeComparator comparator; public SearchTree(TreeComparator comparator) { this.comparator = comparator; } public void add(T object) { if (root != null) root.add(object); else root = new TreeNode(this, object); } public TreeComparator getComparator() { return comparator; } @Override public String toString() { return root.toString(); } }