Serialize arbitrary DOM tree to formatted HTML