private static void addAllChildrenToSet(View rootView,Set<View> theSet){
  if (!(rootView instanceof ViewGroup)) {
    return;
  }
  ViewGroup rootViewGroup=(ViewGroup)rootView;
  for (int i=0; i < rootViewGroup.getChildCount(); ++i) {
    View nextView=rootViewGroup.getChildAt(i);
    theSet.add(nextView);
    addAllChildrenToSet(nextView,theSet);
  }
}

private static void addAllChildrenToSet ( View rootView , Set < View > theSet ) { if ( ! ( rootView instanceof ViewGroup ) ) { return ; } ViewGroup rootViewGroup = ( ViewGroup ) rootView ; for ( int i = 0 ; i < rootViewGroup . getChildCount ( ) ; ++ i ) { View nextView = rootViewGroup . getChildAt ( i ) ; theSet . add ( nextView ) ; addAllChildrenToSet ( nextView , theSet ) ; } }
add all children in the view tree rooted at rootview to a set
