question: private List < ExpandableWrapper < P , C > > generateFlattenedParentChildList ( List < P > parentList , Map < P , Boolean > savedLastExpansionState ) { List < ExpandableWrapper < P , C > > flatItemList = new ArrayList < > ( ) ; int parentCount = parentList . size ( ) ; for ( int i = 0 ; i < parentCount ; i ++ ) { P parent = parentList . get ( i ) ; Boolean lastExpandedState = savedLastExpansionState . get ( parent ) ; boolean shouldExpand = lastExpandedState == null ? parent . isInitiallyExpanded ( ) : lastExpandedState ; generateParentWrapper ( flatItemList , parent , shouldExpand ) ; } return flatItemList ; }
target:  Generates a full list of all parents and their children, in order. Uses Map to preserve last expanded state.