<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _cmp_by_med(path1, path2):
 """Select the path based with lowest MED value. If both paths have same MED, return None. By default, a route that arrives with no MED value is treated as if it had a MED of 0, the most preferred value. RFC says lower MED is preferred over higher MED value. """

    def get_path_med(path):
        med = path.get_pattr(BGP_ATTR_TYPE_MULTI_EXIT_DISC)
        if not med:
            return 0
        return med.value

    med1 = get_path_med(path1)
    med2 = get_path_med(path2)

    if med1 == med2:
        return None
    elif med1 < med2:
        return path1
    return path2