Blocks: Introduce helper function to retrieve hooked blocks
In order to implement Block Hooks (see #59313), we added block_hooks field to the WP_Block_Type class, as well as to block registration related functions. In this follow-up, new helper function gets introduced that is going to compute the list of hooked blocks by other registered blocks for a given block type.
Extracted from https://github.com/WordPress/wordpress-develop/pull/5158 and covered with unit tests.
Props ockham.
Fixes #59383.