Fixed some issues with the Neo4JGraphDatabase.

These issues were discovered while stress testing GeoGit synchronization across multiple nodes.

Fixed two potential infinite loops.
Use a UniqueFactory to ensure that duplicate nodes are not created.