If you ever want to create an unique identifier for a node in JCR, you would’ve to add a mixin type [mix:referenceable] to it. Once you add this mixin, repository creates a UUID (Unique Idnetifier) for the node automatically.
You could use javax.jcr.Session.getNodeByIdentifier(String):Node to retrieve the referenced node with the UUID.
Do note that path in JCR is always unique.