if (unit.getType().equals(UnitType.DEPARTMENT)
if (unit.getType() != null && unit.getType().equals(UnitType.DEPARTMENT)
    public List<IDepartment> getDepartmentWorkingPlace(Date beginDate, Date endDate) {        List<IDepartment> departments = new ArrayList<IDepartment>();        for (IContract contract : this.getContracts()) {            if (contract.belongsToPeriod(beginDate, endDate)) {                IUnit workingUnit = contract.getWorkingUnit();                if (workingUnit != null) {                    if (workingUnit.getTopUnits().isEmpty()) {                        for (IUnit unit : workingUnit.getTopUnits()) {                            if (unit.getType().equals(UnitType.DEPARTMENT)                                    && unit.getDepartment() != null) {                                departments.add(unit.getDepartment());                            }                        }                    } else if (workingUnit.getType().equals(UnitType.DEPARTMENT)                            && workingUnit.getDepartment() != null) {                        departments.add(workingUnit.getDepartment());                    }                }            }        }        return departments;    }