listing parent-child pages in sidebar

Here is the code to put into the sidebar that will list, if the page or its parent has children.
<?php
if($post->post_parent) {
// there is a parent, so
$sTitle = get_the_title($post->post_parent);
$theLink = get_permalink($post->post_parent);
$children = wp_list_pages('sort_column=menu_order&title_li=&child_of='.$post->post_parent.'&echo=0');

} else {
$sTitle = get_the_title($post->ID);
$theLink = get_permalink($post->ID);
$children = wp_list_pages('sort_column=menu_order&title_li=&child_of='.$post->ID.'&echo=0');
}

if ($children) {
?>
<div class="widget" id="subpages">
<h2></h2>
<div class="inside-widget">
<ul>
<?php echo $children; ?>
</ul>
</div>
</div>
<?php
} // End If children
?>