':type head: ListNode
:rtype: ListNode'

def deleteDuplicates(self, head):

    dummy = ListNode(0)
    (pre, cur) = (dummy, head)
    while cur:
        if (cur.next and (cur.next.val == cur.val)):
            val = cur.val
            while (cur and (cur.val == val)):
                cur = cur.next
            pre.next = cur
        else:
            pre.next = cur
            pre = cur
            cur = cur.next
    return dummy.next
