Kara looks for the next leaf in the following order (see picture below):

The following part of the program implements this search:

  kara.move
  if not kara.onLeaf
    turnAround(kara)
    kara.move
    kara.turnRight
    kara.move
    if not kara.onLeaf
      turnAround(kara)
      kara.move
      kara.move
    end
  end
  kara.removeLeaf