SplayTree.js
/**
   * Search if given key is in the tree
   * If found splays the tree base on it
   * if not splays the tree base on last accessed node
   * @param {number} key - The key of entry to search 
   */
Search if given key is in the tree
If found splays the tree base on it
if not splays the tree base on last accessed node
@param {number} key - The key of entry to search
Search if given key is in the tree If found splays the tree base on it if not splays the tree base on last accessed node @param { number } key - The key of entry to search
search(key) {
    let r = this._root;
    while (r) {
      if (key === r.key) {
        this.splay(r);
        return r;
      };
      if (key > r.key) {
        if (r.right) r = r.right;
        else {
          this.splay(r);
          return null;
        }
      } else {
        if (r.left) r = r.left;
        else {
          this.splay(r);
          return null;
        }
      }
    }
  }
search ( key ) { let r = this . _root ; while ( r ) { if ( key === r . key ) { this . splay ( r ) ; return r ; } ; if ( key > r . key ) { if ( r . right ) r = r . right ; else { this . splay ( r ) ; return null ; } } else { if ( r . left ) r = r . left ; else { this . splay ( r ) ; return null ; } } } }
Search if given key is in the tree
 If found splays the tree base on it
 if not splays the tree base on last accessed node
 @param {number} key - The key of entry to search
Search if given key is in the tree If found splays the tree base on it if not splays the tree base on last accessed node @param { number } key - The key of entry to search