Fix a bug with query for entitlements with stacking ID.

Was incorrectly searching only for other entitlements from the same pool
we're dealing with, when we are actually just looking for entitlements
with that stacking ID.
Add query to search for other entitlements in stack.
Re-parent derived pools when possible.

If we're deleting an entitlement which is the source for derived pools,
if the consumer has other entitlements in the same stack, we re-parent
the entitlement.
Check for re-sourcing an derived pool to itself.