Algorithm for transforming XML nodes to JSON (it excludes Attrs)