If you are actually trying to target <a>
tags that appear under these elements and had markup that looked like the following :
<div id="A">
<a href='#'>Test A1</a>
<div id="B">
<a href='#'>Test B</a>
</div>
<a href='#'>Test A2</a>
</div>
You could take advantage of the direct descendant operator >
in CSS to only target elements directly below #A
and not within it's children :
#A > a {
/* This will only target <a> elements that are beneath #A and not in #B */
color: #FFF;
}
And example of this can be seen here and might look like :

Update
It looks like you don't want to just target <a>
tags. If that is the case, you could probably generalize the previous statement by only targeting elements not in B under A :
#A > :not(#B) {
color: #FFF;
}
Updating the example markup :
<div id="A">
<a href='#'>Test A1</a>
<div id="B">
<a href='#'>Test B</a>
</div>
<div id="C">
I'm in C
</div>
<a href='#'>Test A2</a>
still will work as expected :
