I guess it should check if any combination of transactions starting from A or B is the next highest fee rate it would include it.
I guess the possible groups could be:
A
B
A-C
B-D
or A-C B-D E
I am assuming whichever of those groups have the highest fees will be included first?