Parsoid's REST API endpoints currently do some unnecessary HTML string -> DOM object -> HTML string conversions to satisfy `Parsoid.php`'s interface (which in turn was a porting carryover from Parsoid/JS where we had to serialize DOM to string before handing it off to a worker process). But, in Parsoid/PHP world, this DOM -> HTML -> DOM conversion is just an inefficiency which we can purge by having Parsoid,php entry points accept DOM as well.
Note that there are a number of slightly different representations we use for both HTML strings (inline data-mw attributes vs data-mw in JSON blob in `<head>` vs separate JSON blob) and DOM (parsed versions of the different HTML variants, plus the 'internal' version where data-mw is stored in a separate Bag hanging off the DOM). We need to be careful to distinguish which of these is our I/O type.