title: Filtering for seleted categories and subcategories in extbase TYPO3 frontend plugin
body: <p>I am using TYPO3 8.7.</p>
  
  <p>I have got an extension which allows to list events. In the list plugin settings the redactor selects the categories. He wants that all events which have the selected category or a subcategory of it assigned are show in the frontend.</p>
  
  <p>I have been reading the documentation on <a href="https://docs.typo3.org/typo3cms/CoreApiReference/8.7/ApiOverview/Categories/" rel="nofollow noreferrer">docs.typo3.org</a> and have been looking at the class <code>CategoryCollection</code>. As far as I understand, this class helps me to get the keywords for a certain record, but does not help to select records by a keyword.</p>
  
  <p>I would like to filter also for subcategories because it makes the handling of the extension much easier. Let's imagine the following event categories:</p>
  
  <ul>
  <li>course of studies
  
  <ul>
  <li>master's degree</li>
  <li>bachaelor's degree</li>
  </ul></li>
  <li>training
  
  <ul>
  <li>internal training</li>
  <li>external training</li>
  </ul></li>
  </ul>
  
  <p>The backend editor wants to have the choice to display either e.g. internal trainings or all trainings, without activating the parent categories on every event explicitly.</p>
  
  <p>What is the correct way to filter for categories and its subcategories in an extbase repository to display a list of records in the frontend?</p>
  
  <p>Do I have to implement the logic manually to filter for categories and subcategories?</p>