/**
   * Deletes all nodes in the current selection and all attached connections.
   *
   * @param model the {@link GModel} currently being edited
   * @param consumer a consumer to allow custom commands to be appended to the delete command
   */
  public void deleteSelection(
      final GModel model, final BiConsumer<List<GNode>, CompoundCommand> consumer) {

    final List<GNode> nodesToDelete = new ArrayList<>();
    final List<GConnection> connectionsToDelete = new ArrayList<>();

    for (final GNode node : model.getNodes()) {
      if (skinLookup.lookupNode(node).isSelected()) {

        nodesToDelete.add(node);

        for (final GConnector connector : node.getConnectors()) {
          for (final GConnection connection : connector.getConnections()) {

            if (connection != null && !connectionsToDelete.contains(connection)) {
              connectionsToDelete.add(connection);
            }
          }
        }
      }
    }

    for (final GConnection connection : model.getConnections()) {
      if (skinLookup.lookupConnection(connection).isSelected()
          && !connectionsToDelete.contains(connection)) {
        connectionsToDelete.add(connection);
      }
    }

    if (!nodesToDelete.isEmpty() || !connectionsToDelete.isEmpty()) {

      final CompoundCommand command =
          modelEditingManager.remove(nodesToDelete, connectionsToDelete);

      if (consumer != null) {
        consumer.accept(nodesToDelete, command);
      }
    }
  }