This cod can't pass the test case [1,1], output is still [1, 1], but I cant figure out why output is not [].

```
public ListNode deleteDuplicates(ListNode head) {
if(head == null || head.next == null || head.next.next == null){
return head;
}
ListNode dummy = new ListNode(1);
dummy.next = head;
ListNode p = dummy;
ListNode x = p.next;
ListNode y = p.next.next;
while(x != null && y != null){
if(x.val != y.val){
p = p.next;
x = p.next;
y = x.next;
}else{
while(y != null && x.val == y.val){
y = y.next;
}
if(y == null){
p.next = null;
return dummy.next;
}else{
p.next = y;
x = p.next;
y = y.next;
}
}
}
return dummy.next;
}
```