I think no need for the above custom functions, JQuery supports this functionality by nextUntil(selector, filter) function, but you should add filter to only apply your script to the filtered elements not to all next elements:
//hide all .child elements
$('div.child').hide();
$('div.parent').click(function() {
//Toggle (show or hide) only .child elements until finding .parent element.
$(this).nextUntil('div.parent', 'div.child').slideToggle('slow');
});