+ // find the first visible item after it
+ while ( prevItem.IsOk() && !IsVisible(prevItem) )
+ {
+ prevItem = GetNext(prevItem);
+ if ( !prevItem.IsOk() || prevItem == item )
+ {
+ // there are no visible items before item
+ return wxTreeItemId();
+ }
+ }
+
+ // from there we must be able to navigate until this item
+ while ( prevItem.IsOk() )
+ {
+ const wxTreeItemId nextItem = GetNextVisible(prevItem);
+ if ( !nextItem.IsOk() || nextItem == item )
+ break;
+
+ prevItem = nextItem;
+ }
+
+ return prevItem;