code: private static Map<String, String> filterNamespacesToPresent(final Model model,
              final Map<String, String> nsPrefixes) {
          final Map<String, String> resultNses = new HashMap<>();
          final Set<Entry<String, String>> nsSet = nsPrefixes.entrySet();
          final NsIterator nsIt = model.listNameSpaces();
          while (nsIt.hasNext()) {
              final String ns = nsIt.next();
  
              final Optional<Entry<String, String>> nsOpt = nsSet.stream()
                      .filter(nsEntry -> nsEntry.getValue().equals(ns))
                      .findFirst();
              if (nsOpt.isPresent()) {
                  final Entry<String, String> nsMatch = nsOpt.get();
                  resultNses.put(nsMatch.getKey(), nsMatch.getValue());
              }
          }
  
          return resultNses;
      }
docs: Filters the map of namespace prefix mappings to just those containing namespace URIs present in the model
  
  @param model model
  @param nsPrefixes map of namespace to uris
  @return nsPrefixes filtered to namespaces found in the model