title: Reduce strings in python to a specific point
body: <p>I have strings in my python application that look this way:</p>
  
  <pre><code>test1/test2/foo/
  </code></pre>
  
  <p>Everytime I get such a string, I want to reduce it, beginning from the tail and reduced until the fist "/" is reached.</p>
  
  <pre><code>test1/test2/
  </code></pre>
  
  <p>More examples:</p>
  
  <pre><code>foo/foo/foo/foo/foo/  =&gt; foo/foo/foo/foo/
  test/test/            =&gt; test/
  how/to/implement/this =&gt; how/to/implement/
  </code></pre>
  
  <p>How can I implement this in python?</p>
  
  <p>Thanks in advance!</p>