PyExpression (PyBinaryExpression expression, boolean isRight) { PyExpression result = expression; while (result instanceof PyBinaryExpression && (PyTokenTypes.RELATIONAL_OPERATIONS.contains(((PyBinaryExpression)result).getOperator()) || PyTokenTypes.EQUALITY_OPERATIONS.contains(((PyBinaryExpression)result).getOperator()))) { final boolean opposite = isOpposite(((PyBinaryExpression)result).getOperator(), myOperator); if ((isRight && !opposite) || (!isRight && opposite)) { break; } result = ((PyBinaryExpression)result).getRightExpression(); } return result; }