### Question:
DomainSchemaHelper { public static <T extends SchemaElement> T findResourceElement(String resourcePath, List<ResourceElement> resources){ SchemaElement result = null; List<? extends SchemaElement> currentElements = resources; if(resources != null && resourcePath != null){ final String[] pathTokens = resourcePath.split("\\."); for(int i = 0; i < pathTokens.length; i++){ String name = pathTokens[i]; SchemaElement currentResult = null; if (currentElements == null) break; for(SchemaElement element : currentElements){ if(element != null && name.equals(element.getName())){ currentResult = element; break; } } if(i == pathTokens.length - 1){ result = currentResult; } else if(currentResult instanceof AbstractResourceGroupElement){ currentElements = ((AbstractResourceGroupElement) currentResult).getElements(); } else if(currentResult instanceof ConstantsResourceGroupElement){ currentElements = ((ConstantsResourceGroupElement) currentResult).getElements(); } else if(currentResult instanceof ReferenceElement){ SchemaElement referenced = findResourceElement(((ReferenceElement) currentResult).getReferencePath(), resources); if(referenced != null && referenced instanceof AbstractResourceGroupElement){ currentElements = ((AbstractResourceGroupElement) referenced).getElements(); } } else { break; } } } return (T)result; }  static T findResourceElement(String resourcePath, List<ResourceElement> resources); static String getDataIslandPathFromElement(PresentationSingleElement element, List<ResourceElement> clientResources); static String getDataIslandPathFromGroup(PresentationGroupElement group, List<ResourceElement> clientResources,
            List<String> constantGroupNames);  }### Answer:
@Test public void findResourceElement_abstractResourceGroupElement_elements() { SchemaElement result = DomainSchemaHelper.findResourceElement(RESOURCE_NAME + "." + RESOURCE_NAME_2, RESOURCE_ELEMENTS_WITH_SINGLE_ELEMENTS_LIST); assertEquals(RESOURCE_GROUP_ELEMENT_WITH_ANOTHER_RESOURCE_PATH_NAME, result); }
@Test public void findResourceElement_constantsResourceGroupElement_elements() { SchemaElement result = DomainSchemaHelper.findResourceElement(RESOURCE_NAME + "." + RESOURCE_NAME_2, RESOURCE_ELEMENTS_WITH_GROUP_ELEMENTS_LIST); assertEquals(RESOURCE_SINGLE_ELEMENT_WITH_ANOTHER_RESOURCE_PATH_NAME, result); }
@Test public void findResourceElement_referenceElement_elements() { SchemaElement result = DomainSchemaHelper.findResourceElement(RESOURCE_NAME + "." + RESOURCE_NAME_2 + "." + RESOURCE_NAME_3, RESOURCE_ELEMENTS_LIST_WITH_DIFFERENT_ELEMENTS); assertEquals(RESOURCE_NAME_3_ELEMENT, result); }