optimize serialization of hierarchical structures by using swap when resizing subnodes vector