class DroolsDescriptionService implements DescriptionService {

	@Override
	// FIXME: Currently only finds matching description in ancestors.
	// Should search all descendants of the second highest ancestor (the ancestor which is a direct child of root).
	public Set<Description> findMatchingDescriptionInHierarchy(Concept concept, Description description) {
		if(concept == null || concept.getId().equals(Constants.ROOT_CONCEPT)) {
			return Collections.emptySet();
		}
		Set<Description> resultSet = new HashSet<>();

		String languageCode = description.getLanguageCode();
		String term = description.getTerm();
		if(term == null || term.trim().isEmpty()) return Collections.emptySet();
		
		ConceptService conceptService = new DroolsConceptService(repository);
		Set<String> conceptAncestorIds = conceptService.findStatedAncestorsOfConcept(concept);
		for (String conceptAncestorId : conceptAncestorIds) {
			Concept conceptAncestor = repository.getConcept(conceptAncestorId);
			for (Description ancestorsDescription : conceptAncestor.getDescriptions()) {
				if(ancestorsDescription.isActive() && ancestorsDescription.getLanguageCode().equals(languageCode)
						&& ancestorsDescription.getTerm().equals(term)) {
					resultSet.add(ancestorsDescription);
				}
			}
		}
		return resultSet;
	}

	public  DroolsDescriptionService(SnomedDroolsComponentRepository repository, TestResourceProvider testResourceProvider);

}