private void createInsertList(final IItem item,List<IItem> tempList,List<IItem> insertList,int depth,int removed){
  if (!tempList.contains(item)) {
    tempList.add(item);
    if (depth == 0) {
      insertList.add(item);
    }
    if (item.getItems() != null) {
      depth++;
      for (      IItem child : item.getItems()) {
        createInsertList(child,tempList,insertList,depth,removed);
      }
    }
  }
 else {
    insertList.remove(item);
    removed++;
  }
}

private void createInsertList ( final IItem item , List < IItem > tempList , List < IItem > insertList , int depth , int removed ) { if ( ! tempList . contains ( item ) ) { tempList . add ( item ) ; if ( depth == 0 ) { insertList . add ( item ) ; } if ( item . getItems ( ) != null ) { depth ++ ; for ( IItem child : item . getItems ( ) ) { createInsertList ( child , tempList , insertList , depth , removed ) ; } } } else { insertList . remove ( item ) ; removed ++ ; } }
recursive helper method for createinsertlist
