Try improving `isSharedWith`

This commit tries to improve the `isSharedWith` SQL function to deal
with arbitrarily deep shared nodes in the hierarchy.
4 jobs for adinapoli/issue-273-part-2 in 69 minutes and 39 seconds (queued for 2 seconds)
latest
Status Job ID Name Coverage
  Stack
passed #10297
stack

00:03:51

 
  Cabal
passed #10298
cabal

00:30:45

 
  Bench
passed #10299
bench

00:13:45

 
  Test
passed #10300
test

00:21:16