Multiple Conditions for Child Page Title

Based on the comment exchange, here’s what I think you’re after:

<h1><?php echo get_the_title( $post->post_parent ? $post->post_parent : $post->ID ) ?></h1>

<?php if ( $list = wp_list_pages( "echo=0&child_of=$post->ID" ) ) : ?>

    <h2>Select a sub-page</h2>
    <ul>
        <?php echo $list ?>
    </ul>

<?php elseif ( $post->parent ) : ?>

    <h2><?php the_title() ?></h2>

<?php endif ?>

error code: 523