How the following Depth first traversal code works?
BST.prototype.depthFirstTraversal = function(iteratorFunc, order) {
if (order === 'pre-order')
iteratorFunc(this.value);
if (this.left)
this.left.depthFirstTraversal(iteratorFunc, order);
if (order === 'in-order')
iteratorFunc(this.value);
if (this.right)
this.right.depthFirstTraversal(iteratorFunc, order);
if (order === 'post-order')
iteratorFunc(this.value);
};