You haven't shown the definition of the data structure or how the linked list was created.
You first need to work out which loop the crash occurs in. Then you need to examine the values that you use to work out which one is null. Then you need to look back at your program to work out why you set it to null when it shouldn't be.