def _get2DOverlapBox(box1, box2):
    """Get 2D box where the two boxes overlap"""
    result = {
              'left': max(box1['left'], box2['left']),
              'top': max(box1['top'], box2['top']),
              'right': min(box1['right'], box2['right']),
              'bottom': min(box1['bottom'], box2['bottom']),
              }
    # ensure that right>=left and bottom>=top
    result['right'] = max(result['left'], result['right'])
    result['bottom'] = max(result['top'], result['bottom'])
    return result