Set<M> (C targetClass, Set<? super C> visited) { LinkedHashSet<M> result = myTargetClassToMemberInfosListMap.get(targetClass); if(result == null) { result = new LinkedHashSet<>(); Set<C> subclasses = getSubclasses(targetClass); for (C subclass : subclasses) { List<M> memberInfos = getClassMemberInfos(subclass); result.addAll(memberInfos); } for (C subclass : subclasses) { if (visited.add(subclass)) { result.addAll(getIntermediateClassesMemberInfosList(subclass, visited)); } } myTargetClassToMemberInfosListMap.put(targetClass, result); } return result; }