/// This function substitutes the term 't' at the position 'p' with 'new_subterm', see [super::substitute].
/// This is the same as [data_substitute], but it uses a [DataSubstitutionBuilder] to store the arguments temporarily.
// else recurse deeper into 't', do not subtract 1 from the index, since we are using DataPosition
let new_child = substitute_rec(tp, &t.arg(new_child_index).into(), new_subterm, p, args, depth + 1);
// Avoid the (more expensive) DataApplication constructor by simply having the data_function_symbol in args.
// TODO: When write is dropped we check whether all terms where inserted, but this clear violates that assumption.
THREAD_TERM_POOL.with_borrow(|tp| data_substitute(tp, &t.copy(), t0.clone(), &DataPosition::new(&[1, 1])));