(function () {
    'use strict';

    var BSTNode = function (value) {
        this.key = value;
        this.right = null;
        this.left = null;
    };

    var BST = function () {
        this.root = null;
    };

    BST.prototype.add = function (value) {
        var newNode = new BSTNode(value);

        if (this.root === null) {
            this.root = newNode;
            console.log('just added root node...');
        } else {
            addNode(this.root, newNode);
        }
    };

    BST.prototype.inOrderTraversal = function (cb) {
        inOrderTraverseNode(this.root, cb);
    };

    BST.prototype.preOrderTraverseNode = function (cb) {
        preOrderTraverseNode(this.root, cb);
    };

    BST.prototype.postOrderTraverseNode = function (cb) {
        postOrderTraverseNode(this.root, cb);
    };

    BST.prototype.min = function () {
        return minNode(this.root);
    };

    BST.prototype.max = function () {
        return maxNode(this.root);
    };

    module.exports = BST;

    if (module.parent === null) {
        console.log('running this as the main module...');
        main();
    }

    function main() {
        var bst = new BST();
        bst.add(18);
        bst.add(4);
        bst.add(32);
        bst.add(5);
        bst.add(1);

        console.log('min value: ' + bst.min());
        console.log('max value: ' + bst.max());
    }

    /********** helper functions **********/
    function addNode(node, newNode) {
        if (newNode.key < node.key) {
            if (node.left === null) {
                node.left = newNode;
            } else {
                addNode(node.left, newNode);
            }

        } else {
            if (node.right === null) {
                node.right = newNode;
            } else {
                addNode(node.right, newNode);
            }

        }
    }

    function inOrderTraverseNode(node, cb) {
        if (node !== null) {
            inOrderTraverseNode(node.left, cb);
            cb(node.key);
            inOrderTraverseNode(node.right, cb);
        }
    }

    function preOrderTraverseNode(node, cb) {
        if (node !== null) {
            cb(node.key);
            preOrderTraverseNode(node.left, cb);
            preOrderTraverseNode(node.right, cb);
        }
    }

    function postOrderTraverseNode(node, cb) {
        if (node !== null) {
            postOrderTraverseNode(node.left, cb);
            postOrderTraverseNode(node.right, cb);
            cb(node.key);
        }
    }

    function minNode(node) {
        if (node) {
            while (node && node.left !== null) {
                node = node.left;
            }
            return node.key;
        }
        return null;
    }

    function maxNode(node) {
        if (node) {
            while (node && node.right !== null) {
                node = node.right;
            }
            return node.key;
        }
        return null;
    }

}());

@@ -370,60 +370,8 @@
 de;%0A
-            console.log('just added root node...');%0A
     
@@ -434,32 +434,135 @@
       %7D%0A    %7D;%0A%0A
+    BST.prototype.contains = function (value) %7B%0A        return containsNode(this.root, value);%0A    %7D;%0A%0A
     BST.prototyp
@@ -1099,67 +1099,8 @@
 ) %7B%0A
-        console.log('running this as the main module...');%0A
     
@@ -1268,24 +1268,116 @@
 st.add(1);%0A%0A
+        bst.inOrderTraversal(function (value) %7B%0A            console.log(value);%0A        %7D)%0A%0A
         cons
@@ -1456,24 +1456,134 @@
 bst.max());%0A
+        console.log('contains 5: ' + bst.contains(5));%0A        console.log('contains 7: ' + bst.contains(7));%0A
     %7D%0A%0A    /
@@ -2039,32 +2039,372 @@
        %7D%0A    %7D%0A%0A
+    function containsNode(node, value) %7B%0A        if (node === null) %7B%0A            return false;%0A        %7D%0A%0A        if (value %3C node.key) %7B%0A            return containsNode(node.left, value);%0A        %7D else if (value %3E node.key) %7B%0A            return containsNode(node.right, value);%0A        %7D else %7B%0A            return true;%0A        %7D%0A    %7D%0A%0A
     function inO

Add contains method