private STNode<Key, Value> put(STNode<Key, Value> h, Key key, Value val)
	{
		if (h == null)
			return new STNode<Key, Value>(key, val, 1, 0, RED);
		else
		{
			int cmp = key.compareTo(h.key);

			if (cmp < 0)
				h.left = put(h.left, key, val);
			else if (cmp > 0)
				h.right = put(h.right, key, val);
			else
				h.val = val;

			// on the way up
			if (isRed(h.right) && !isRed(h.left))
				h = rotateLeft(h);
			if (isRed(h.left) && isRed(h.left.left))
				h = rotateRight(h);
			if (isRed(h.left) && isRed(h.right))
				flipColor(h);

			h.N = size(h.left) + size(h.right) + 1;
			h.h = Math.max(height(h.left), height(h.right)) + 1;
			return h;
		}
	}