You can try
/Root/SomeElement//Wanted[not(ancestor::UnWanted)]
This excludes all elements Wantedthat are children, grandchildren, etc. (at any level) of the element UnWanted. If you want to exclude only those elements Wantedthat are a direct child UnWanted(but still include those that are grandchildren, etc.), change ancestor::toparent::
/Root/SomeElement//Wanted[not(parent::UnWanted)]
source
share