basis.data.dataset: fix Extract to work correctly with cycles