@TargetApi(Build.VERSION_CODES.LOLLIPOP) public OptionScanNode buildTreeFromWindowList(List<SwitchAccessWindowInfo> windowList,OptionScanNode contextMenuTree){
  contextMenuTree=(contextMenuTree == null) ? new ClearFocusNode() : contextMenuTree;
  if (windowList == null || windowList.size() == 0) {
    return contextMenuTree;
  }
  List<OptionScanNode> treeNodes=new ArrayList<>();
  for (  SwitchAccessWindowInfo window : windowList) {
    SwitchAccessNodeCompat windowRoot=window.getRoot();
    if (windowRoot != null) {
      treeNodes.addAll(getNodeListFromNodeTree(windowRoot));
      windowRoot.recycle();
    }
  }
  return buildTreeFromNodeList(treeNodes,OPTION_SCAN_SELECTION_NODE,contextMenuTree);
}

@ TargetApi ( Build . VERSION_CODES . LOLLIPOP ) public OptionScanNode buildTreeFromWindowList ( List < SwitchAccessWindowInfo > windowList , OptionScanNode contextMenuTree ) { contextMenuTree = ( contextMenuTree == null ) ? new ClearFocusNode ( ) : contextMenuTree ; if ( windowList == null || windowList . size ( ) == 0 ) { return contextMenuTree ; } List < OptionScanNode > treeNodes = new ArrayList < > ( ) ; for ( SwitchAccessWindowInfo window : windowList ) { SwitchAccessNodeCompat windowRoot = window . getRoot ( ) ; if ( windowRoot != null ) { treeNodes . addAll ( getNodeListFromNodeTree ( windowRoot ) ) ; windowRoot . recycle ( ) ; } } return buildTreeFromNodeList ( treeNodes , OPTION_SCAN_SELECTION_NODE , contextMenuTree ) ; }
build an n - ary tree from a window list . construct a list of all the nodes as an intermediate state and then construct the n - ary tree from this list .
