fix NPE in getTreeNodeForDocRef and remove not possible else condition