public static Collection<CommunicationSummaryStatistics> buildCommunicationSummaryTree(Collection<CommunicationSummaryStatistics> nodes,Set<String> endpoints){
  Map<String,CommunicationSummaryStatistics> nodeMap=new HashMap<String,CommunicationSummaryStatistics>();
  for (  CommunicationSummaryStatistics css : nodes) {
    nodeMap.put(css.getId(),css);
  }
  List<CommunicationSummaryStatistics> ret=new ArrayList<>();
  for (  String endpoint : endpoints) {
    CommunicationSummaryStatistics n=nodeMap.get(EndpointUtil.encodeClientURI(endpoint));
    if (n == null) {
      n=nodeMap.get(endpoint);
    }
    if (n != null) {
      CommunicationSummaryStatistics rootNode=new CommunicationSummaryStatistics(n);
      initCommunicationSummaryTreeNode(rootNode,nodeMap,new HashSet<>(Collections.singleton(rootNode.getId())));
      ret.add(rootNode);
    }
  }
  return ret;
}

public static Collection < CommunicationSummaryStatistics > buildCommunicationSummaryTree ( Collection < CommunicationSummaryStatistics > nodes , Set < String > endpoints ) { Map < String , CommunicationSummaryStatistics > nodeMap = new HashMap < String , CommunicationSummaryStatistics > ( ) ; for ( CommunicationSummaryStatistics css : nodes ) { nodeMap . put ( css . getId ( ) , css ) ; } List < CommunicationSummaryStatistics > ret = new ArrayList < > ( ) ; for ( String endpoint : endpoints ) { CommunicationSummaryStatistics n = nodeMap . get ( EndpointUtil . encodeClientURI ( endpoint ) ) ; if ( n == null ) { n = nodeMap . get ( endpoint ) ; } if ( n != null ) { CommunicationSummaryStatistics rootNode = new CommunicationSummaryStatistics ( n ) ; initCommunicationSummaryTreeNode ( rootNode , nodeMap , new HashSet < > ( Collections . singleton ( rootNode . getId ( ) ) ) ) ; ret . add ( rootNode ) ; } } return ret ; }
this method returns the supplied list of flat nodes as a set of tree structures with related nodes .
