Check if a specific block is in the_content

if ( has_blocks( $post->post_content ) ) {
    $relatedpostsfound = 0;
    $blocks = parse_blocks( $post->post_content );
    foreach ($blocks as $block) {
        if (( 'core/block' === $block['blockName'] ) || ( 'core/group' === $block['blockName'] )) {
            $block_blocks = parse_blocks( get_post( $block['attrs']['ref'] )->post_content );
            foreach ($block_blocks as $block_block) {
                if ( $block_block['blockName'] === 'acf/related-posts' ) { $relatedpostsfound = 1; }
                $block_block_innerblocks = $block_block['innerBlocks'];
                foreach ($block_block_innerblocks as $block_block_innerblock) {
                    if ( $block_block_innerblock['blockName'] === 'acf/related-posts' ) { $relatedpostsfound = 1; }
                }
            } 
        }
        if ( $block['blockName'] === 'acf/related-posts' ) { $relatedpostsfound = 1; }
    }
}