This part is a little cryptic.
Please add comment about exactly what getArrayElementName does and why we decide that 'nodeName' may be erroneous.
Also, add a space between 'if' and '(' please, as the rest of the source code.