SMTestProxy (SMTestProxy parentSuite, String fullName, boolean preferSuite) { if (myTreeBuildBeforeStart) { Set<SMTestProxy> acceptedProxies = new LinkedHashSet<>(); Collection<? extends SMTestProxy> children = myCurrentChildren.get(fullName); if (children == null) { initCurrentChildren(parentSuite, preferSuite); children = myCurrentChildren.get(fullName); } if (children != null) { //null if child started second time for (SMTestProxy proxy : children) { if (!proxy.isFinal() || preferSuite && proxy.isSuite()) { acceptedProxies.add(proxy); } } if (!acceptedProxies.isEmpty()) { SMTestProxy accepted = null; for (SMTestProxy proxy : acceptedProxies) { if (proxy.isSuite() == preferSuite && proxy.getParent() == parentSuite) { if (!proxy.isFinal()) { return proxy; } if (accepted == null) { accepted = proxy; } } } return accepted != null ? accepted : acceptedProxies.iterator().next(); } } } return null; }