You have to take a manual lock for that otherwise you get into typical race conditions.
Probably easiest by locking both nodes in question.
There is a lock management API on the Neo4j Transaction, but you can also just remove an non-existent property which also takes a write lock.
We probably have to expose locking in SDN at some point. If you think that's a good idea, please raise a JIRA issue.