- try (final RegistrationTreeSnapshot<AbstractDOMDataTreeChangeListenerRegistration<?>> snapshot
- = takeSnapshot()) {
- final List<PathArgument> toLookup
- = ImmutableList.copyOf(candidate.getRootPath().getPathArguments());
- lookupAndNotify(toLookup, 0, snapshot.getRootNode(), candidate);
+ try (var snapshot = takeSnapshot()) {
+ final List<PathArgument> toLookup = ImmutableList.copyOf(candidate.getRootPath().getPathArguments());
+ final ListMultimap<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate> listenerChanges =
+ Multimaps.newListMultimap(new IdentityHashMap<>(), ArrayList::new);
+ lookupAndNotify(toLookup, 0, snapshot.getRootNode(), candidate, listenerChanges);
+
+ for (var entry : Multimaps.asMap(listenerChanges).entrySet()) {
+ notifyListener(entry.getKey(), entry.getValue());
+ }
+
+ return !listenerChanges.isEmpty();