You can write a simple function that checks whether an object is this object itself or one of its children/grandchildren/etc:
bool IsARelative(GameObject target) {
var me = transform;
var t = target.transform;
while (t != null) {
if (t == me) return true;
t = t.parent;
}
return false;
}
Then use that to filter the collection of all objects with a tag down to only those that are not this object or its descendents:
IEnumerator<GameObject> NonRelativesWithTag(string tag) {
var allWithTag = FindObjectsWithTag(tag);
foreach(var candidate in allWithTag) {
if (!IsARelative(candidate))
yield return candidate;
}
}
You can then walk through that iterator to act on each such object you find:
void DoSomethingWithNonRelatives() {
var nonRelatives = FindNonRelativesWithTag("Some Tag");
while (nonRelatives.MoveNext()) {
var found = nonRelatives.current;
// Do something with `found`.
}
}