function leftRotation(node) {
		var p = node, 
			q = node.right, 
			b, ah, bh, ch;
		if (!q) { return p; }   // No change
		b = q.left;
		// Alter tree structure
		if (p.parent) {
			q.parent = p.parent;
			if (p.parent.left === p) { p.parent.left = q; } else { p.parent.right = q; }
		} else {
			q.parent = null;
		}
		q.left = p;
		p.parent = q;
		p.right = b;
		if (b) { b.parent = p; }
		// Update heights
		ah = p.left ? p.left.height : 0;
		bh = b ? b.height : 0;
		ch = q.right ? q.right.height : 0;
		p.height = Math.max(ah, bh) + 1;
		q.height = Math.max(ch, p.height) + 1;
		return q;
	}
/**
	 * Perform a left rotation of the tree if possible
	 * and return the root of the resulting tree
	 * The resulting tree's nodes' heights are also updated
	 */
Perform a left rotation of the tree if possible
and return the root of the resulting tree
The resulting tree's nodes' heights are also updated
Perform a left rotation of the tree if possible and return the root of the resulting tree The resulting tree ' s nodes ' heights are also updated
function leftRotation(node) {
		var p = node, 
			q = node.right, 
			b, ah, bh, ch;
		if (!q) { return p; }   
		b = q.left;
		if (p.parent) {
			q.parent = p.parent;
			if (p.parent.left === p) { p.parent.left = q; } else { p.parent.right = q; }
		} else {
			q.parent = null;
		}
		q.left = p;
		p.parent = q;
		p.right = b;
		if (b) { b.parent = p; }
		ah = p.left ? p.left.height : 0;
		bh = b ? b.height : 0;
		ch = q.right ? q.right.height : 0;
		p.height = Math.max(ah, bh) + 1;
		q.height = Math.max(ch, p.height) + 1;
		return q;
	}
function leftRotation ( node ) { var p = node , q = node . right , b , ah , bh , ch ; if ( ! q ) { return p ; } b = q . left ; if ( p . parent ) { q . parent = p . parent ; if ( p . parent . left === p ) { p . parent . left = q ; } else { p . parent . right = q ; } } else { q . parent = null ; } q . left = p ; p . parent = q ; p . right = b ; if ( b ) { b . parent = p ; } ah = p . left ? p . left . height : 0 ; bh = b ? b . height : 0 ; ch = q . right ? q . right . height : 0 ; p . height = Math . max ( ah , bh ) + 1 ; q . height = Math . max ( ch , p . height ) + 1 ; return q ; }
Perform a left rotation of the tree if possible
 and return the root of the resulting tree
 The resulting tree's nodes' heights are also updated
Perform a left rotation of the tree if possible and return the root of the resulting tree The resulting tree ' s nodes ' heights are also updated
// No change // Alter tree structure // Update heights