<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _prepare_axes(node, sort_key):
 """ Sort axes and combine those that point to the same target and go in the same direction. """

    links = node.links
    o_links = node._overlapping_links
    overlap = {ax2 for ax in links for ax2 in o_links.get(ax, [])}
    axes = []
    for axis in sorted(links.keys(), key=sort_key):
        if axis in overlap: continue
        tgt = links[axis]
        if axis in o_links:
            s, e = axis[0], axis[-1]
            axis = '%s%s%s' % (
                s, '&'.join(a[1:-1] for a in [axis] + o_links[axis]), e
            )
        axes.append((axis, tgt))
    return axes