show posts under subcategory only when in that subcategory

If you use the follow code:

<?php  $cats = get_categories('child_of=6'); 

        foreach ($cats as $cat) :
            $this_category = get_category($cat);
            $args = array(
                'category__in' => array($cat->term_id)
            );
            $my_query = new WP_Query($args); 
            if ($my_query->have_posts()) : ?>

            <li><a href="https://wordpress.stackexchange.com/questions/41725/<?php echo get_category_link($cat); ?>"><?php echo $cat->name; ?></a>

            <?php if ($this_category->category_parent != 0) { ?>

                <ul class="children">
                <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>     
                <?php /*general loop output; for instance: */ ?>
                <li>- <a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>

                <?php endwhile; ?>
            </ul>
            <?php } ?>
            </li>

            <?php else : 
                echo 'No Posts for '.$cat->name;                
            endif; 
       endforeach;     
?>

you will get something like:

subcategory 1

* - Post title 1
* - Post title 2

subcategory 2

* - Post title 3

As you can see per sub category will appears only the Posts in that sub category.
Note I move $this_category = get_category($cat); inside the foreach.