What you ask is called recursion in categories and is not a simple task.
I don't know an extension able to do it, but there are some tools by Magnus.
*
https://tools.wmflabs.org/catscan2/catscan2.php
*
https://tools.wmflabs.org/quick-intersection/index.php
Nemo