<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def port_id_from_name(port_name, device_id, nodes):
 """ Get the port ID when given a port name :param str port_name: port name :param str device_id: device ID :param list nodes: list of nodes from :py:meth:`generate_nodes` :return: port ID :rtype: int """

        port_id = None
        for node in nodes:
            if device_id == node['id']:
                for port in node['ports']:
                    if port_name == port['name']:
                        port_id = port['id']
                        break
                break
        return port_id