def transform_snake_list(linked_snake):
  """Transforms a linked snake list to a canonical snake list, i.e.
     from something of the form:

       (x1,y1,x2,y2,itype,previous_snake)

     to something of the form:

       [ ..., (x1,y1,x2,y2,ityp), ... ]

     This is needed to go from the linked list snake search to a snake list
     that is more suitable to other parts of the program."""

  lcs = []
  while (linked_snake):
    (x1,y1,x2,y2,itype,linked_snake) = linked_snake
    lcs.insert(0,(x1,y1,x2,y2,itype))
  return lcs