The advanced solution is a Walker. But simplest sotution is a recursive function, which will work just like Walker. You can use one below:
function wpse343409_get_recursive_posts( $type="page", $parent_id = 0 ) { // default parent 0 means only top level posts
$posts = new WP_Query( array(
'post_type' => $type,
'posts_per_page' => -1,
'post_parent' => $parent_id,
'ignore_sticky_posts' => 1, // In case of sticky posts, page may fall into an infinite loop
) );
if( $posts->have_posts() ) :
echo '<ul>';
while( $posts->have_posts() ) : $posts->the_post();
printf( '<li><a href="https://wordpress.stackexchange.com/questions/343409/%s">%s</a>', esc_url( get_permalink() ), esc_html( get_the_title() ) );
wpse343409_get_recursive_posts( $type, get_the_ID() );
echo '</li>';
endwhile;
echo '</ul>';
endif;
}
wpse343409_get_recursive_posts( 'sections' );