You can develop a Joomla plugin of the group hikashop implementing the trigger onBeforeCartUpdate( &$cartClass, &$cart, &$product_id, &$quantity, &$add, &$type,&$resetCartWhenUpdate,&$force,&$do) so that each time something is added/removed to cart, you can check if there are enough products from that category to add/keep/remove the free product in the cart.
You can also implement the onBeforeCalculateProductPriceForQuantity trigger to set the price of that product to 0 before the calculations for the total of the cart.