answered 5 years ago
I suggest to take inspiration from
src/sage/combinat/free_prelie_algebra.py:class FreePreLieAlgebra(CombinatorialFreeModule):
which define another kind of non-associative algebra on a vector space spanned by trees.