Show links to child pages on both parent AND child pages

This seemed to work nicely for me;

<?php
    $children = get_pages('child_of=".$post->ID);
    if( count( $children ) != 0 ) {
        $id = $post->ID;
    } else {
        $id = $post->post_parent;
    }
    $args = array(
        "post_type' => 'page',
        'post_parent' => $id,
        'posts_per_page' => -1
    );
    $system_query = new WP_Query($args);
    if ($system_query->have_posts()) :
    while ($system_query->have_posts()) : $system_query->the_post();
?>

    <!-- list of child pages here -->

<?php endwhile; endif; wp_rest_postdata(); ?>