Loop through Custom Post Type, and then show children within each iteration

Placing the following code within the WP_Query loop works:

<?php
                $parent_page_id = ( '0' != $post->post_parent ? $post->post_parent : $post->ID ); 
                $mypages = get_pages( array( 'child_of' => $parent_page_id,  'post_type' => 'programs' ) );

                foreach( $mypages as $page ) {      
                    $content = $page->post_content;
                    if ( ! $content ) // Check for empty page
                        continue;

                    $content = apply_filters( 'the_content', $content );
                ?>

                <h2><a href="https://wordpress.stackexchange.com/questions/90404/<?php echo get_page_link( $page->ID ); ?>"><?php echo $page->post_title; ?></a></h2>
                <div class="entry"><?php echo $content; ?></div>

                <?php }  ?>

This solution is taken from: http://codex.wordpress.org/Function_Reference/get_pages

tech