code: private boolean isExternallyConnected(final WiresConnector connector)
      {
          WiresShape headShape = null;
          WiresShape tailShape = null;
          if (connector.getHeadConnection().getMagnet() != null)
          {
              headShape = connector.getHeadConnection().getMagnet().getMagnets().getWiresShape();
          }
          if (connector.getTailConnection().getMagnet() != null)
          {
              tailShape = connector.getTailConnection().getMagnet().getMagnets().getWiresShape();
          }
          final boolean hasHeadShapeNotInSelection = (headShape != null) && (m_selected.findParentIfInSelection(headShape) == null);
          final boolean hasTailShapeNotInSelection = (tailShape != null) && (m_selected.findParentIfInSelection(tailShape) == null);
  
          return hasHeadShapeNotInSelection || hasTailShapeNotInSelection;
      }
docs: returns wheher the connector is connected to a shape not in the selection.
  As this could be connected to a nested shape, it iterates from that shape (not in the selection) until it finds it's parent in the selection or it returns null.
  @param connector
  @return