Boolean (@NotNull PyEvaluator evaluator, @Nullable PyExpression expression) { final Object result = evaluator.evaluate(expression); if (result instanceof Boolean) { return (Boolean)result; } else if (result instanceof Integer) { return (Integer)result != 0; } else if (result instanceof String) { return !((String)result).isEmpty(); } else if (result instanceof Collection) { return !((Collection<?>)result).isEmpty(); } else if (result instanceof Map) { return !((Map<?, ?>)result).isEmpty(); } return null; }