<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def edit_securitygroup_rule(self, group_id, rule_id, remote_ip=None, remote_group=None, direction=None, ethertype=None, port_max=None, port_min=None, protocol=None):
 """Edit a security group rule. :param int group_id: The ID of the security group the rule belongs to :param int rule_id: The ID of the rule to edit :param str remote_ip: The remote IP or CIDR to enforce the rule on :param int remote_group: The remote security group ID to enforce the rule on :param str direction: The direction to enforce (egress or ingress) :param str ethertype: The ethertype to enforce (IPv4 or IPv6) :param str port_max: The upper port bound to enforce :param str port_min: The lower port bound to enforce :param str protocol: The protocol to enforce (icmp, udp, tcp) """

        successful = False
        obj = {}
        if remote_ip is not None:
            obj['remoteIp'] = remote_ip
        if remote_group is not None:
            obj['remoteGroupId'] = remote_group
        if direction is not None:
            obj['direction'] = direction
        if ethertype is not None:
            obj['ethertype'] = ethertype
        if port_max is not None:
            obj['portRangeMax'] = port_max
        if port_min is not None:
            obj['portRangeMin'] = port_min
        if protocol is not None:
            obj['protocol'] = protocol

        if obj:
            obj['id'] = rule_id
            successful = self.security_group.editRules([obj], id=group_id)

        return successful