private void collectItems(List<Node> result,List<Node> nodes){
  if (nodes != null) {
    for (    Node node : nodes) {
      result.add(node);
      collectItems(result,node.getSubNodes());
    }
  }
}

private void collectItems ( List < Node > result , List < Node > nodes ) { if ( nodes != null ) { for ( Node node : nodes ) { result . add ( node ) ; collectItems ( result , node . getSubNodes ( ) ) ; } } }
adds recurrently nodes and their sub - nodes to provided list .
