<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_instances_in_role(self, role, state_filter=None):
 """ Get all the instances in a role, filtered by state. @param role: the name of the role @param state_filter: the state that the instance should be in (e.g. "running"), or None for all states """

    self._check_role_name(role)
    instances = []
    
    for instance in self._get_instances(self._group_name_for_role(role), 
                                       state_filter):            
      instances.append(Instance(instance.id, instance.dns_name, 
                                instance.private_dns_name, 
                                instance.private_ip_address))
      
    return instances