private List<MountedNodeStore> getContributingStores(String path, Function<MountedNodeStore, Iterable<String>> childrenProvider) { Mount owningMount = mip.getMountByPath(path); if (!owningMount.isDefault() && nodeStoresByMount.containsKey(owningMount)) { MountedNodeStore nodeStore = nodeStoresByMount.get(owningMount); if (nodeStore != globalStore) { return singletonList(nodeStore); } } // scenario 2 - multiple mounts participate List<MountedNodeStore> mountedStores = newArrayList(); mountedStores.add(globalStore); // we need mounts placed exactly one level beneath this path Collection<Mount> mounts = mip.getMountsPlacedDirectlyUnder(path); // query the mounts next for (MountedNodeStore mountedNodeStore : nonDefaultStores) { final Mount mount = mountedNodeStore.getMount(); if (mounts.contains(mount)) { mountedStores.add(mountedNodeStore); } else if (hasChildrenContainingPathFragmentName(mountedNodeStore, path, childrenProvider)) { mountedStores.add(mountedNodeStore); } } return mountedStores; }