Change parent term id or class

<?php
$taxonomy = 'material';
// Gets every &quot;category&quot; (term) in this taxonomy to get the respective posts
$terms = get_terms( $taxonomy );
foreach( $terms as $term ) :
  echo '<div class=&quot;lessonmaterials&quot;><h3>'. $term->name. '</h3>';
  if ( $term->parent == 0 ) continue;

  // rest of your code here

  $resourcequery = new WP_Query(array(
    'post_type' => 'lesson',
    'taxonomy' => $taxonomy,
    'term' => $term->slug,
    'posts_per_page' => -1
    ));

if( $resourcequery->have_posts() ): while( $resourcequery->have_posts() ) : $resourcequery->the_post();
?>
<div class=&quot;lessoncontent&quot;>
  <a href=&quot;<?php the_permalink() ?>&quot;><?php the_title(); ?></a>    <br />
<?php the_content(); ?>
</div>
        <?php endwhile; ?>
</div>
        <?php else :
        echo 'No Posts for '.$cat->name;
        endif; 

    endforeach;
	?>

Im using this to post all the posts from a child custom term on a parent term page. Is there a way to change the parent term title id or class or just separate it on a div? Im thinking of using a conditional statement but everytime i use this it just show all my posts on that parent term too.

if($term->parent > 0)
{
// THIS IS A CHILD PAGE
// .. DO STUFF HERE..
}
else
{
// THIS IS THE PARENT PAGE
// .. DO OTHER STUFF HERE..
}