if (unit != null) { for (Contract contract : unit.getWorkingContracts(begin, end)) { employees.add(contract.getEmployee()); } for (Unit subUnit : unit.getSubUnits()) { for (Contract contract : subUnit.getWorkingContracts(begin, end)) { employees.add(contract.getEmployee()); } }
if (departmentUnit != null) { readAndSaveEmployees(departmentUnit, employees, begin, end);
    public List<Employee> getWorkingEmployees(Date begin, Date end) {        Unit unit = this.getUnit();        Set<Employee> employees = new HashSet<Employee>();        if (unit != null) {            for (Contract contract : unit.getWorkingContracts(begin, end)) {                employees.add(contract.getEmployee());            }            for (Unit subUnit : unit.getSubUnits()) {                for (Contract contract : subUnit.getWorkingContracts(begin, end)) {                    employees.add(contract.getEmployee());                }            }        }        return new ArrayList<Employee>(employees);    }