Impl of linkedlist node test in java