Kara walks around the trees in an endless loop. In each step, he considers the sensors "tree front?" and "tree right?" to determine the appropriate action.

while (true) {                                
  if (kara.treeFront() && kara.treeRight()) { 
    kara.turnLeft();                          
  }
  else if (!kara.treeFront())                 
    if (kara.treeRight()) {                   
      kara.move();                            
    }
    else {                                    
      kara.turnRight();                       
      kara.move();                            
    }
}