} else if (unit.getType() != null && unit.getType().equals(UnitType.DEPARTMENT)) {
} else if (unitDepartment(unit, onlyActiveEmployees)) {
    private Department getEmployeeUnitDepartment(Unit unit, boolean onlyActiveEmployees) {        List<Unit> allTopUnits = unit.getTopUnits();        if (!allTopUnits.isEmpty()) {            for (Unit topUnit : allTopUnits) {                if (topUnit.getType() != null                        && topUnit.getType().equals(UnitType.DEPARTMENT)                        && topUnit.getDepartment() != null                        && (!onlyActiveEmployees || topUnit.getDepartment()                                .getCurrentActiveWorkingEmployees().contains(this))) {                    return topUnit.getDepartment();                }            }        } else if (unit.getType() != null && unit.getType().equals(UnitType.DEPARTMENT)) {            return unit.getDepartment();        }        return null;    }