HashSet<String> directDLSet = new HashSet<String>();
    static List<DistributionList> getDistributionLists(String addrs[], boolean directOnly, Map<String, String> via) throws ServiceException {        List<DistributionList> directDLs = Provisioning.getInstance().getAllDistributionListsForAddresses(addrs);                 HashSet<String> checked = new HashSet<String>();        List<DistributionList> result = new ArrayList<DistributionList>();                Stack<DistributionList> dlsToCheck = new Stack<DistributionList>();                for (DistributionList dl : directDLs) {            dlsToCheck.push(dl);        }        while (!dlsToCheck.isEmpty()) {            DistributionList dl = dlsToCheck.pop();            if (checked.contains(dl.getId())) continue; // skip if already in groups            result.add(dl);            checked.add(dl.getId());            if (directOnly) continue;            List<DistributionList> newLists = dl.getDistributionLists(true, null);            for (DistributionList newDl: newLists) {                if (via != null) via.put(newDl.getName(), dl.getName());                dlsToCheck.push(newDl);            }        }        Collections.sort(result);        return result;    }