Ceck, if a tab already exists.

Ceck, if a tab already exists.

In a callback, I open tabs like this:

  1.           $('#packageTable tbody').on( 'click', 'button', function () {
  2.             var data = table.row($(this).parents('tr')).data();
  3.             var tabId = "tab-" + data.id;
  4.             $("<li id=" + tabId + "><a href='" + tabId + "'>" + data.package + "</a</li>")
  5.                 .appendTo("#tabs .ui-tabs-nav");
  6.             $("#tabs").tabs("refresh");
  7.         });

In other words: The tabs have an associated id. (The tabId.) Now, I'd like to change the callback as follows:
Check, if a tab with the given id is already open. If so, do nothing. Otherwise, create the new tab.

How would I do that?