title: Get a top level from Path object of pathlib
body: <p>I use <code>pathlib</code> to match all files recursively to filter the files based on their content. Then I would like to find what is the top level of the folder of this file. Assume the following. I have a file in the folder:</p>
  
  <p><code>a/b/c/file.log</code></p>
  
  <p>I do the search from the level <code>a</code>:</p>
  
  <pre><code>for f in path_data.glob("**/*"):
      if something inside file f:
           # I would like to get in what folder this file is, i.e. 'b'
  </code></pre>
  
  <p>I now that I can get all parents levels using:</p>
  
  <ul>
  <li><code>f.parents</code> would give me <code>b/c</code></li>
  <li><code>f.parent</code> would give me <code>c</code></li>
  <li><code>f.name</code> would give me <code>file.log</code></li>
  </ul>
  
  <p>But how could I get <code>b</code>?</p>
  
  <p>Just to precise: the number of levels where the file is stored is not known.</p>
  
  <p>UPD: I know I could do it with split, but I would like to know if there is a proper API to do that. I couldn't find it.</p>