private boolean shouldRemoveNode ( HistoryNode node ) { if ( node == null ) { return true ; } int sizeOfChildren = 0 ; if ( node . children != null ) { sizeOfChildren = node . children . size ( ) ; } if ( sizeOfChildren > 0 ) { return false ; } int sizeOfNotifications = 0 ; if ( node . notifications != null ) { for ( List < HistoryTreeEntry > notiList : node . notifications . values ( ) ) { if ( notiList != null ) { sizeOfNotifications += notiList . size ( ) ; if ( sizeOfNotifications > 0 ) { return false ; } } } } return true ; }
Should remove the node from the history tree if both the notifications and children list are empty .