function SearchTree(){this.rootNode=null;this.numNodes=0}function SearchTreeNode(a){this.payload=a;this.children={};this.numChildren=0}SearchTree.prototype={setRootNode:function(a){this.rootNode=a},insert:function(a,b){if(!this.rootNode){if(a.length){this.setRootNode(new SearchTreeNode(null));this.numNodes++}else{this.setRootNode(new SearchTreeNode(b));this.numNodes++;return}}this.rootNode.insert(a,b)},remove:function(a){this.rootNode.remove(a)},destroyTree:function(){this.rootNode=null;this.numNodes=0},search:function(a,d){var c=this.rootNode;for(var b=0;b<a.length;b++){var f=a[b];if(f in c.children){c=c.children[f]}else{if(d){return{result:c.payload,prefix:true}}else{return null}}}return{result:c.payload,prefix:false}},stringify:function(){return JSON.stringify(this)},populateFromJSON:function(a){var b=JSON.parse(a);this.rootNode=b.rootNode;this.numNodes=b.numNodes}};SearchTreeNode.prototype={insert:function(a,c){var b=a.splice(0,1);if(!a.length){if(b in this.children){this.children[b].payload=c}else{this.children[b]=new SearchTreeNode(c);this.numChildren++}}else{if(!(b in this.children)){this.children[b]=new SearchTreeNode(null);this.numChildren++}this.children[b].insert(a,c)}},remove:function(a){var b=a.splice(0,1);if(!a.length){if(b in this.children){if(this.children[b].numChildren){this.children[b].payload=null}else{delete this.children[b];this.numChildren--}}}else{if(b in this.children){this.children[b].remove(a)}}}};
function SearchTree(){this.rootNode=null;this.numNodes=0}function SearchTreeNode(a){this.payload=a;this.children={};this.numChildren=0}
SearchTree.prototype={setRootNode:function(a){this.rootNode=a},insert:function(a,c){if(!this.rootNode)if(a.length)this.setRootNode(new SearchTreeNode(null)),this.numNodes++;else{this.setRootNode(new SearchTreeNode(c));this.numNodes++;return}this.rootNode.insert(a,c)},remove:function(a){this.rootNode.remove(a)},destroyTree:function(){this.rootNode=null;this.numNodes=0},search:function(a,c){for(var b=this.rootNode,e=0;e<a.length;e++){var d=a[e];if(d in b.children)b=b.children[d];else return c?{result:b.payload,
prefix:!0}:null}return{result:b.payload,prefix:!1}},dfs:function(a){function c(a,b,e){if(b.payload.typeid==a)return b;var d=null,f;for(f in b.children){if(d)break;e[b.children[f].payload.typeid]={e:f,parent:b.payload.typeid};d=c(a,b.children[f],e)}return d}for(var b={},e=c(a,this.rootNode,b),d=[];a in b;)d.push(b[a].e),a=b[a].parent;b=d.reverse();return{node:e,edges:b}},stringify:function(){return JSON.stringify(this)},populateFromJSON:function(a){a=JSON.parse(a);this.rootNode=a.rootNode;this.numNodes=
a.numNodes}};
SearchTreeNode.prototype={insert:function(a,c){var b=a.splice(0,1);a.length?(b in this.children||(this.children[b]=new SearchTreeNode(null),this.numChildren++),this.children[b].insert(a,c)):b in this.children?this.children[b].payload=c:(this.children[b]=new SearchTreeNode(c),this.numChildren++)},remove:function(a){var c=a.splice(0,1);a.length?c in this.children&&this.children[c].remove(a):c in this.children&&(this.children[c].numChildren?this.children[c].payload=null:(delete this.children[c],this.numChildren--))},
getChildren:function(){var a=[],c;for(c in this.children)a.push(this.children[c]);return a}};

Update searchtree library