title: Remove element from postgres array if string not exists in sub select
body: <p>Hello I have a couple of <code>ltree paths</code> in <code>postgres</code>, now I need to remove a label if it does not exists in a <code>subquery</code>.</p>
  
  <pre><code>SELECT 
    string_to_array(stacks.path::text, '.') as path 
  FROM 
    stacks 
  WHERE 
    stacks.id IN (SELECT 
                    subscriptions.stack_id 
                  FROM 
                    subscriptions
                  WHERE 
                    subscriptions.owner_id = 'user')
  </code></pre>
  
  <p>The path is made up of stacks.id fx 'f34f.23fas.2fs2'. Now I want to remove each label of the path not contained in subscriptions.stack_id. Fx lets say a user has subscribed to the stacks 23fas and 2fs2. Since '23fas' is a child of 'f34f', it´s path will return 'f34f.23fas'. But I want to remove 'f34f' from '23fas'´s path. Meaning I want to remove all labels not contained in subscriptions.stack_id. </p>
  
  <p>This is how far I got, I cant figure out how to remove a element if it does not come up in a given <code>subquery</code>. </p>