Use the Resource API to determine the node type (page, asset, experience fragment).
Use the ReferenceSearch API to get references for the node.
String nodeType = getNodeType(resource);List<Reference> references = getReferences(resource);
Resource resource = resourceResolver.getResource(reso...