private void removeTvShowEpisode(TvShowEpisode episode){
synchronized (root) {
    TvShowEpisodeTreeNode child=(TvShowEpisodeTreeNode)nodeMap.get(episode);
    TvShowSeasonTreeNode parent=null;
    if (child != null) {
      parent=(TvShowSeasonTreeNode)child.getParent();
    }
    if (parent != null && child != null) {
      int index=getIndexOfChild(parent,child);
      parent.remove(child);
      nodeMap.remove(episode);
      episode.removePropertyChangeListener(propertyChangeListener);
      if (index > -1) {
        TreeModelEvent event=new TreeModelEvent(this,parent.getPath(),new int[]{index},new Object[]{child});
        for (        TreeModelListener listener : listeners) {
          try {
            listener.treeNodesRemoved(event);
          }
 catch (          NullPointerException|ArrayIndexOutOfBoundsException ignored) {
          }
        }
      }
      if (parent.getChildCount() == 0) {
        TvShowSeason season=null;
        for (        Entry<Object,TreeNode> entry : nodeMap.entrySet()) {
          if (entry.getValue() == parent) {
            season=(TvShowSeason)entry.getKey();
          }
        }
        if (season != null) {
          removeTvShowSeason(season);
        }
      }
    }
  }
}

private void removeTvShowEpisode ( TvShowEpisode episode ) { synchronized ( root ) { TvShowEpisodeTreeNode child = ( TvShowEpisodeTreeNode ) nodeMap . get ( episode ) ; TvShowSeasonTreeNode parent = null ; if ( child != null ) { parent = ( TvShowSeasonTreeNode ) child . getParent ( ) ; } if ( parent != null && child != null ) { int index = getIndexOfChild ( parent , child ) ; parent . remove ( child ) ; nodeMap . remove ( episode ) ; episode . removePropertyChangeListener ( propertyChangeListener ) ; if ( index > - 1 ) { TreeModelEvent event = new TreeModelEvent ( this , parent . getPath ( ) , new int [ ] { index } , new Object [ ] { child } ) ; for ( TreeModelListener listener : listeners ) { try { listener . treeNodesRemoved ( event ) ; } catch ( NullPointerException | ArrayIndexOutOfBoundsException ignored ) { } } } if ( parent . getChildCount ( ) == 0 ) { TvShowSeason season = null ; for ( Entry < Object , TreeNode > entry : nodeMap . entrySet ( ) ) { if ( entry . getValue ( ) == parent ) { season = ( TvShowSeason ) entry . getKey ( ) ; } } if ( season != null ) { removeTvShowSeason ( season ) ; } } } } }
removes the tv show episode .
