function splay(i, t, comparator) {
    if (t === null) return t;
    var l, r, y;
    var N = new Node();
    l = r = N;

    while (true) {
      var cmp = comparator(i, t.key); //if (i < t.key) {

      if (cmp < 0) {
        if (t.left === null) break; //if (i < t.left.key) {

        if (comparator(i, t.left.key) < 0) {
          y = t.left;
          /* rotate right */

          t.left = y.right;
          y.right = t;
          t = y;
          if (t.left === null) break;
        }

        r.left = t;
        /* link right */

        r = t;
        t = t.left; //} else if (i > t.key) {
      } else if (cmp > 0) {
        if (t.right === null) break; //if (i > t.right.key) {

        if (comparator(i, t.right.key) > 0) {
          y = t.right;
          /* rotate left */

          t.right = y.left;
          y.left = t;
          t = y;
          if (t.right === null) break;
        }

        l.right = t;
        /* link left */

        l = t;
        t = t.right;
      } else {
        break;
      }
    }
    /* assemble */


    l.right = t.left;
    r.left = t.right;
    t.left = N.right;
    t.right = N.left;
    return t;
  }
/**
   * Simple top down splay, not requiring i to be in the tree t.
   * @param {Key} i
   * @param {Node?} t
   * @param {Comparator} comparator
   */
Simple top down splay, not requiring i to be in the tree t.
Simple top down splay not requiring i to be in the tree t .
function splay(i, t, comparator) {
    if (t === null) return t;
    var l, r, y;
    var N = new Node();
    l = r = N;
    while (true) {
      var cmp = comparator(i, t.key); 
      if (cmp < 0) {
        if (t.left === null) break; 
        if (comparator(i, t.left.key) < 0) {
          y = t.left;
          t.left = y.right;
          y.right = t;
          t = y;
          if (t.left === null) break;
        }
        r.left = t;
        r = t;
        t = t.left; 
      } else if (cmp > 0) {
        if (t.right === null) break; 
        if (comparator(i, t.right.key) > 0) {
          y = t.right;
          t.right = y.left;
          y.left = t;
          t = y;
          if (t.right === null) break;
        }
        l.right = t;
        l = t;
        t = t.right;
      } else {
        break;
      }
    }
    l.right = t.left;
    r.left = t.right;
    t.left = N.right;
    t.right = N.left;
    return t;
  }
function splay ( i , t , comparator ) { if ( t === null ) return t ; var l , r , y ; var N = new Node ( ) ; l = r = N ; while ( true ) { var cmp = comparator ( i , t . key ) ; if ( cmp < 0 ) { if ( t . left === null ) break ; if ( comparator ( i , t . left . key ) < 0 ) { y = t . left ; t . left = y . right ; y . right = t ; t = y ; if ( t . left === null ) break ; } r . left = t ; r = t ; t = t . left ; } else if ( cmp > 0 ) { if ( t . right === null ) break ; if ( comparator ( i , t . right . key ) > 0 ) { y = t . right ; t . right = y . left ; y . left = t ; t = y ; if ( t . right === null ) break ; } l . right = t ; l = t ; t = t . right ; } else { break ; } } l . right = t . left ; r . left = t . right ; t . left = N . right ; t . right = N . left ; return t ; }
Simple top down splay, not requiring i to be in the tree t.
 @param {Key} i
 @param {Node?}
Simple top down splay not requiring i to be in the tree t . @param { Key } i @param { Node? }
//if (i < t.key) { //if (i < t.left.key) { /* rotate right */ /* link right */ //} else if (i > t.key) { //if (i > t.right.key) { /* rotate left */ /* link left */ /* assemble */