How to write an if statement which reads: ‘if is this custom post type or a child of it do the following’?

I accidentally got the answer:

        <?php
            global $post;
            $the_post_parent = $post->post_parent;
            $the_post_ID = $post->ID;
            $cat_posts = get_posts('post_type=bbp_forum&posts_per_page=-1');
            print_r($post_parent);
        ?>
        <?php foreach ( $cat_posts as $post ) : ?>
            <li <?php if ( $post->ID == $the_post_ID || $post->ID == $the_post_parent ) echo 'class="current"'; ?>>
                <a href="https://wordpress.stackexchange.com/questions/13966/<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
            </li>
        <?php endforeach; ?>

I would appreciate if someone explain it to me.