enhance rewrite_shared_optional so one can specify where the new identity relation should be added (used by cw multi-sources planner)