AI OnAI Off
I guess you are not using EPiServer.Find in your project? Otherwise that would be the nicest solution.
From your pseudocode it looks like you are interested of a certain block type? If that is the case then you might want to use IContentModelUsage.ListContentOfContentType that will give you references to alll instances of your block type.
You would then still have to load and iterate over them to find which that matches your criteria, but with this approach you only load blocks of your wanted type and not all blocks as the case will be with GetDecendents.
I want to search a block with specific property set to some value. This is my code:
I am caching this, but is there a way to improve performances by search from specific block folder ID on? How would I see the ID of the folder in edit mode?