Buggy code:
public class Tree extends Composite { TreeItem [ ] items ; TreeColumn [ ] columns ; TreeColumn sortColumn ; int [ ] childIds ; GC paintGC ; int clickCount ; int sortDirection ; int columnCount ; int column_id ; int idCount ; int anchorFirst ; int anchorLast ; int headerHeight ; int itemHeight ; boolean ignoreRedraw ; boolean ignoreSelect ; boolean wasSelected ; boolean ignoreExpand ; boolean wasExpanded ; boolean inClearAll ; Rectangle imageBounds ; TreeItem showItem ; int lastHittest ; int visibleCount ; static final int CHECK_COLUMN_ID = 1024 ; static final int COLUMN_ID = 1025 ; static final int GRID_WIDTH = 1 ; static final int ICON_AND_TEXT_GAP = 4 ; static final int CELL_CONTENT_INSET = 12 ; static final int DISCLOSURE_COLUMN_EDGE_INSET = 8 ; static final int DISCLOSURE_TRIANGLE_AND_CONTENT_GAP = 8 ; public Tree ( Composite parent , int style ) { } void _addListener ( int eventType , Listener listener ) { } int _getId ( ) { } int [ ] _getIds ( int count ) { } TreeItem _getItem ( int id , boolean create ) { } TreeItem _getItem ( TreeItem parentItem , int index ) { } public void addSelectionListener ( SelectionListener listener ) { } public void addTreeListener ( TreeListener listener ) { } int calculateWidth ( int [ ] ids , GC gc ) { } int callPaintEventHandler ( int control , int damageRgn , int visibleRgn , int theEvent , int nextHandler ) { GC currentGC = paintGC ; if ( currentGC == null ) { GCData data = new GCData ( ) ; data . paintEvent = theEvent ; data . visibleRgn = visibleRgn ; paintGC = GC . carbon_new ( this , data ) ; } int result = super . callPaintEventHandler ( control , damageRgn , visibleRgn , theEvent , nextHandler ) ; if ( OS . HIVIEW ) { Control widget = findBackgroundControl ( ) ; if ( widget != null ) { Rectangle rect = getClientArea ( ) ; int headerHeight = getHeaderHeight ( ) ; rect . y += headerHeight ; rect . height -= headerHeight ; if ( ( childIds ) != null ) { int [ ] ids = childIds ; int [ ] state = new int [ 1 ] ; int index = ( ids . length ) - 1 ; while ( true ) { while ( ( index >= 0 ) && ( ( ids [ index ] ) == 0 ) ) index -- ; if ( index < 0 ) break ; OS . GetDataBrowserItemState ( handle , ids [ index ] , state ) ; if ( ( ( state [ 0 ] ) & ( OS . kDataBrowserContainerIsOpen ) ) != 0 ) { TreeItem item = items [ ( ( ids [ index ] ) - 1 ) ] ; <START_BUG> if ( item != null ) { <END_BUG> ids = item . childIds ; index = ( ids . length ) - 1 ; } else { break ; } } else { break ; } } if ( ( index >= 0 ) && ( ( ids [ index ] ) != 0 ) ) { Rect itemRect = new Rect ( ) ; if ( ( columnCount ) == 0 ) { OS . GetDataBrowserItemPartBounds ( handle , ids [ index ] , column_id , kDataBrowserPropertyEnclosingPart , itemRect ) ; } else { for ( int i = 0 ; i < ( columnCount ) ; i ++ ) { if ( ( OS . GetDataBrowserItemPartBounds ( handle , ids [ index ] , columns [ i ] . id , kDataBrowserPropertyEnclosingPart , itemRect ) ) == ( OS . noErr ) ) { break ; } } } rect . height = ( ( rect . y ) + ( rect . height ) ) - ( itemRect . bottom ) ; rect . y = itemRect . bottom ; } } fillBackground ( handle , paintGC . handle , rect ) ; } } if ( currentGC == null ) { paintGC . dispose ( ) ; paintGC = null ; } return result ; } boolean checkData ( TreeItem item , boolean redraw ) { } static int checkStyle ( int style ) { } protected void checkSubclass ( ) { } void clear ( TreeItem parentItem , int index , boolean all ) { } void clearAll ( TreeItem parentItem , boolean all ) { } public void clear ( int index , boolean all ) { } public void clearAll ( boolean all ) { } public Point computeSize ( int wHint , int hHint , boolean changed ) { } public Rectangle computeTrim ( int x , int y , int width , int height ) { } boolean contains ( int shellX , int shellY ) { } void createHandle ( ) { } void createItem ( TreeColumn column , int index ) { } void createItem ( TreeItem item , TreeItem parentItem , int index ) { } ScrollBar createScrollBar ( int style ) { } void createWidget ( ) { } Color defaultBackground ( ) { } Color defaultForeground ( ) { } int defaultThemeFont ( ) { } public void deselectAll ( ) { } void destroyItem ( TreeColumn column ) { } void destroyItem ( TreeItem item ) { } int drawItemProc ( int browser , int id , int property , int itemState , int theRect , int gdDepth , int colorDevice ) { } void fixScrollBar ( ) { } int getCheckColumnWidth ( ) { } public Rectangle getClientArea ( ) { } public TreeColumn getColumn ( int index ) { } public int getColumnCount ( ) { } public int [ ] getColumnOrder ( ) { } public TreeColumn [ ] getColumns ( ) { } int getGap ( ) { } public int getGridLineWidth ( ) { } public int getHeaderHeight ( ) { }

Fix:
if ( ( item != null ) && ( ( item . childIds ) != null ) ) {