private List<SNode> getNodesImpl(String conceptFQName, boolean includeInherited) { if (includeInherited) { Set<String> allDescendantsOfConcept = ConceptDescendantsCache.getInstance().getDescendants(conceptFQName); final ArrayList<List<SNode>> nodesOfConcept = new ArrayList<List<SNode>>(allDescendantsOfConcept.size()); int cnt = 0; synchronized (myNodeMap) { // utilize the fact values in map are immutable for (String d : allDescendantsOfConcept) { List<SNode> n = myNodeMap.get(d); nodesOfConcept.add(n); cnt += n.size(); } } final ArrayList<SNode> result = new ArrayList<SNode>(cnt); for (List<SNode> l : nodesOfConcept) { result.addAll(l); } return result; } else { synchronized (myNodeMap) { return myNodeMap.get(conceptFQName); } } }