} else {
try {
final String uuid = getIdentifier(tree);
String reference = weak ? PropertyType.TYPENAME_WEAKREFERENCE : PropertyType.TYPENAME_REFERENCE;
String pName = propertyName == null ? "*" : propertyName; // TODO: sanitize against injection attacks!?
Map<String, ? extends CoreValue> bindings = Collections.singletonMap("uuid", new StringValue(uuid));
Result result = queryEngine.executeQuery(
"SELECT * FROM [nt:base] WHERE PROPERTY([" + pName + "], '" + reference + "') = $uuid",
Query.JCR_SQL2, Long.MAX_VALUE, 0, bindings, root, new NamePathMapper.Default());