code: private static Set<String> getAnnotationLevelSet(SDocumentGraph graph,
            String namespace, Class<? extends SNode> type) {
      Set<String> result = new TreeSet<>();
  
      if (graph != null) {
        List<? extends SNode> nodes;
        // catch most common cases directly
        if (SSpan.class == type) {
          nodes = graph.getSpans();
        } else if (SToken.class == type) {
          nodes = graph.getTokens();
        } else {
          nodes = graph.getNodes();
        }
        if (nodes != null) {
          for (SNode n : nodes) {
            if (type.isAssignableFrom(n.getClass())) {
              for (SLayer layer : n.getLayers()) {
                if (namespace == null || namespace.equals(layer.getName())) {
                  for (SAnnotation anno : n.getAnnotations()) {
                    result.add(anno.getQName());
                  }
                  // we got all annotations of this node, jump to next node
                  break;
                } // end if namespace equals layer name
              } // end for each layer
            }
          } // end for each node
        }
      }
  
      return result;
    }
docs: Get the qualified name of all annotations belonging to spans having a
  specific namespace.
  
  @param graph The graph.
  @param namespace The namespace of the node (not the annotation) to search
  for.
  @param type Which type of nodes to include
  @return