pytree: add support for writing (particle) objects