You're still naming the methods backwards from the way I believe the pattern is traditionally used. Visitable (or Element) usually has an accept method and Visitor has a visitX method. I'm going to use the traditional naming scheme to avoid confusing myself :-)
IMO the easiest way to get this to work is by having multiple methods on your Visitor interface, one for each type of child. It doesn't matter if the children are the same language type or not, if they are semantically different they should be handled by different methods.
You should also try to avoid polluting the Visitor implementation with details about the structure of the Visitable. In order to do this I would move the accept method up into the Visitable interface instead of exposing childA and childB on that interface. Then each implementation of Visitable can decide which method on the visitor to call for each child. This communicates to the visitor all of the "location" context and gives you a nice, clean, decoupled solution.
Here's an example of what I'm thinking. Again, I've swapped the method names back to what I'm used to.
interface Visitable {
accept(Visitor v)
}
interface Visitor {
visitA(Node a)
visitB(Node b)
}
class Container implements Visitable {
private Node childA
private Node childB
...
void accept(Visitor v) {
v.visitA(childA)
v.visitB(childB)
}
}
Now you get to have an implementation of Visitor that has 2 different methods, one for handling A children and one for handling B children.