Javadoc and NPE

Added javadoc to method and avoiding NPE,
when node has no children.