Add circular dependency integrity check.

This commit adds a check to prevent circular dependencies in branch nodes. If a circular dependency occurs
then a panic will be called and the commit will be prevented. This only works for a single branch level
and will not recursively search the tree.
Merge pull request #175 from benbjohnson/check-loop

Add circular dependency integrity check.