'C# VSTO -- Detection of unused slide layouts

I am programming a PowerPoint add-in in C# (VSTO).

About my problem, I want to delete all master slides that are not used. I have been programming this function for quite a long time now and I can't get it to work. I also can't find a solution anywhere.

In the attached picture, you can see what I want to check.

Check picture

I hope one of you can help me, I thank you in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source