categories

foreach ( $parent_cats as $parent_cat) {
    $child_cats = some wp functions to get child cats of current parent category
    foreach ( $child_cats as $child_cat ) {
        $child_cat_post = get the post of child category
    }
}