function Tree(parent,value){
this.parent = parent || null;
this.value = value || 0;
this.left = null;
this.right = null;
}
Tree.prototype.setLeft = function(value){
this.left = new Tree(value);
}
Tree.prototype.setRight = function(value){
this.right = new Tree(value);
}
function Arbrain(code){
this.top = new Tree(null,0);
this.code = code;
this.current = this.top;
this.index = 0;
}
Arbrain.prototype.step = function(){
switch(this.code[this.index]){