private Node<T> balance(Node<T> h) {
        // assert (h != null);

        if (h.right != null && h.right.red) h = rotateLeft(h);
        if (h.left != null && h.left.red && h.left.left != null && h.left.left.red) h = rotateRight(h);
        if (h.left != null && h.left.red && h.right != null && h.right.red) flipColors(h);

        h.n = (h.left == null ? 0 : h.left.n) + (h.right == null ? 0 : h.right.n) + 1;
        return h;
    }
private Node < T > balance ( Node < T > h ) { if ( h . right != null && h . right . red ) h = rotateLeft ( h ) ; if ( h . left != null && h . left . red && h . left . left != null && h . left . left . red ) h = rotateRight ( h ) ; if ( h . left != null && h . left . red && h . right != null && h . right . red ) flipColors ( h ) ; h . n = ( h . left == null ? 0 : h . left . n ) + ( h . right == null ? 0 : h . right . n ) + 1 ; return h ; }
restore red-black tree invariant