because from traverse you take back null. First, you initialize your array and later you are change her to null.