Fix infinite loop and allow add node without parent
Merge pull request #1 from fdeandao/master

Fix infinite loop and allow add node without parent