Trim and shape tree-structured objects for stdout using nodejs