for ( ;; )
{
// don't go into infinite loop
- if ( start_node && node == start_node )
+ if ( start_node && node && node == start_node )
break;
// Have we come to the last or first item on the panel?
if ( !node )
{
+ if ( !start_node )
+ {
+ // exit now as otherwise we'd loop forever
+ break;
+ }
+
if ( !goingDown )
{
// Check if our (maybe grand) parent is another panel: if this