public static ListNode mergeSortedListRec(ListNode head1, ListNode head2) {
        if (head1 == null) {
            return head2;
        }
        if (head2 == null) {
            return head1;
        }
        ListNode retNode = null;
        if (head1.val < head2.val) {
            retNode = head1;
            retNode.next = mergeSortedListRec(head1, head2);
        } else {
            retNode = head2;
            retNode.next = mergeSortedListRec(head1, head2);
        }
        return retNode;
    }