function getDescendants(el, curset) {
curset = curset || $(""); // default to empty set
var id = el.data('tt-id');
var children = $("tr[data-tt-parent-id="+id+"]");
if (children.length) {
curset = curset.add(children);
children.each(function() {
curset = curset.add(getDescendants($(this), curset));
});
}
return curset;
}
There's probably more idiomatic ways to write this without having to reassign curset = ...
in several places, but this works.