Buggy code:
public int getColumnCount ( ) { } public TreeColumn [ ] getColumns ( ) { } Color getConnectorColor ( ) { } Image getExpandedImage ( ) { } Image getGrayUncheckedImage ( ) { } public int getGridLineWidth ( ) { } public int getHeaderHeight ( ) { } int getHeaderPadding ( ) { } public boolean getHeaderVisible ( ) { } public TreeItem getItem ( Point point ) { } public int getItemCount ( ) { } public int getItemHeight ( ) { } public TreeItem [ ] getItems ( ) { } int getItemY ( TreeItem item ) { } public boolean getLinesVisible ( ) { } public TreeItem getParentItem ( ) { } public TreeItem [ ] getSelection ( ) { } public int getSelectionCount ( ) { } int getSelectionIndex ( TreeItem item ) { } public TreeItem getTopItem ( ) { } Image getUncheckedImage ( ) { } void handleEvents ( Event event ) { } void headerOnMouseDown ( Event event ) { } void headerOnMouseExit ( ) { } void headerOnMouseMove ( Event event ) { } void headerOnMouseUp ( Event event ) { } void headerOnPaint ( Event event ) { } void headerPaintShadow ( GC gc , Rectangle bounds , boolean paintHLines , boolean paintVLines ) { } int indexOf ( TreeColumn column ) { } static void initImages ( final Display display ) { } void makeAvailable ( TreeItem item ) { } void makeDescendentsAvailable ( TreeItem item , TreeItem [ ] descendents ) { } void makeDescendentsUnavailable ( TreeItem item , TreeItem [ ] descendents ) { } void onArrowDown ( int stateMask ) { } void onArrowLeft ( int stateMask ) { } void onArrowRight ( int stateMask ) { } void onArrowUp ( int stateMask ) { } void onCR ( ) { } void onDispose ( ) { } void onEnd ( int stateMask ) { } void onFocusIn ( ) { } void onFocusOut ( ) { } void onHome ( int stateMask ) { } void onKeyDown ( Event event ) { } void onMouseDoubleClick ( Event event ) { } void onMouseDown ( Event event ) { } void onMouseUp ( Event event ) { } void onPageDown ( int stateMask ) { } void onPageUp ( int stateMask ) { } void onPaint ( Event event ) { } void onResize ( Event event ) { } void onScrollHorizontal ( Event event ) { } void onScrollVertical ( Event event ) { } void onSpace ( ) { } void reassignFocus ( ) { } void redrawFromItemDownwards ( int index ) { } void redrawItem ( int itemIndex , boolean focusBoundsOnly ) { } void redrawItems ( int startIndex , int endIndex , boolean focusBoundsOnly ) { } public void removeAll ( ) { } void removeSelectedItem ( int index ) { } public void removeSelectionListener ( SelectionListener listener ) { } public void removeTreeListener ( TreeListener listener ) { } public void selectAll ( ) { } void selectItem ( TreeItem item , boolean addToSelection ) { } void setFocusItem ( TreeItem item , boolean redrawOldFocus ) { } public void setFont ( Font value ) { } void setHeaderImageHeight ( int value ) { } public void setHeaderVisible ( boolean value ) { } void setImageHeight ( int value ) { } public void setInsertMark ( TreeItem item , boolean before ) { } public void setLinesVisible ( boolean value ) { } public void setSelection ( TreeItem [ ] items ) { checkWidget ( ) ; if ( items == null ) error ( ERROR_NULL_ARGUMENT ) ; if ( ( ( items . length ) == 0 ) || ( ( ( ( style ) & ( SWT . SINGLE ) ) != 0 ) && ( ( items . length ) > 1 ) ) ) { deselectAll ( ) ; return ; } TreeItem [ ] oldSelection = selectedItems ; int index = 0 ; selectedItems = new TreeItem [ items . length ] ; for ( int i = 0 ; i < ( items . length ) ; i ++ ) { TreeItem item = items [ i ] ; <START_BUG> if ( ( item != null ) && ( ! ( item . isSelected ( ) ) ) ) { <END_BUG> selectedItems [ ( index ++ ) ] = item ; } } if ( index != ( items . length ) ) { TreeItem [ ] temp = new TreeItem [ index ] ; System . arraycopy ( selectedItems , 0 , temp , 0 , index ) ; selectedItems = temp ; } if ( ( selectedItems . length ) == 0 ) { deselectAll ( ) ; return ; } for ( int i = 0 ; i < ( oldSelection . length ) ; i ++ ) { if ( ! ( oldSelection [ i ] . isSelected ( ) ) ) { int availableIndex = oldSelection [ i ] . availableIndex ; if ( availableIndex != ( - 1 ) ) { redrawItem ( availableIndex , true ) ; } } } showItem ( selectedItems [ 0 ] ) ; setFocusItem ( selectedItems [ 0 ] , true ) ; for ( int i = 0 ; i < ( selectedItems . length ) ; i ++ ) { int availableIndex = selectedItems [ i ] . availableIndex ; if ( availableIndex != ( - 1 ) ) { redrawItem ( availableIndex , true ) ; } } } public void setTopItem ( TreeItem item ) { } public void showColumn ( TreeColumn column ) { } public void showItem ( TreeItem item ) { } public void showSelection ( ) { } void updateColumnWidth ( TreeColumn column , int width ) { } void updateHorizontalBar ( ) { } void updateHorizontalBar ( int newRightX , int rightXchange ) { } void updateVerticalBar ( ) { } }

Fix:
if ( ( ( item != null ) && ( ( item . parent ) == ( this ) ) ) && ( ! ( item . isSelected ( ) ) ) ) {