Optimized Kleene-star: just adds ε-transitions from
input to the output, and back.
function rep(fragment) {
  fragment.in.addTransition(EPSILON, fragment.out);
  fragment.out.addTransition(EPSILON, fragment.in);
  return fragment;
}