That can be helpful for reducing dependencies
Loose coupling : The code that calls an interface method, does not need to know anything about the implementation.
Interfaces are also used as markers to denote certain type of behaviour.
For the directories given by you ... according my algorithm it will be
c:\checko~1\foo
c:\checko~1\foo
Does that mean your problem is solved? If not, what's still missing?
What I suggested could be as simple as a call to Set.contains, the duration of which would hardly be measurable compared to DB operations.
The obvious approach would be to check whether any "node" (or whatever a, b, c, d are) has already been visited.