public ListNode deleteDuplicates(ListNode head) {
		if (head == null || head.next == null) {
			return head;
		}

		ListNode h = head, guard = new ListNode(0);
		guard.next = head;

		while (h.next != null) {
			if (h.val == h.next.val) {
				h = h.next;
			} else {
				if (guard.next != h) {
					if (guard.next == head) {
						h = h.next;
						head = h;
						guard.next = h;
					} else {
						h = h.next;
						guard.next = h;
					}
				} else {
					guard = h;
					h = h.next;
					guard.next = h;
				}
			}
		}

		if (guard.next != h) {
			if (guard.next == head) {
				return null;
			} else {
				guard.next = null;
			}
		}
		return head;
	}