this is quite complicated to find out in the end. i wonder if we should do that in a phpcr-utils helper. it feels pretty overkill but i dd not find anything simpler