Help convert one type of javascript object to another type

well the original object is like a hierarchy of items (like a graph) & I want this to be converted to sort of a level order traversal.