If I understand you correctly, this should work:
$first_post = true;
$post_parent = 0;
foreach ( $books as $book ) {
$post = array(
'post_title' => esc_html__( 'Post', 'book-cpt' ),
'post_content' => 'test',
'post_status' => 'publish',
'post_type' => 'book',
'post_parent' => $post_parent
);
$book_id = wp_insert_post( $post );
if ($first_post) {
$post_parent = $book_id;
$first_post = false;
}
};