function traceMappings(tree) {
        const gen = new genMapping.GenMapping({ file: tree.map.file });
        const { sources: rootSources, map } = tree;
        const rootNames = map.names;
        const rootMappings = traceMapping.decodedMappings(map);
        for (let i = 0; i < rootMappings.length; i++) {
            const segments = rootMappings[i];
            let lastSource = null;
            let lastSourceLine = null;
            let lastSourceColumn = null;
            for (let j = 0; j < segments.length; j++) {
                const segment = segments[j];
                const genCol = segment[0];
                let traced = SOURCELESS_MAPPING;
                // 1-length segments only move the current generated column, there's no source information
                // to gather from it.
                if (segment.length !== 1) {
                    const source = rootSources[segment[1]];
                    traced = originalPositionFor(source, segment[2], segment[3], segment.length === 5 ? rootNames[segment[4]] : '');
                    // If the trace is invalid, then the trace ran into a sourcemap that doesn't contain a
                    // respective segment into an original source.
                    if (traced == null)
                        continue;
                }
                // So we traced a segment down into its original source file. Now push a
                // new segment pointing to this location.
                const { column, line, name, content, source } = traced;
                if (line === lastSourceLine && column === lastSourceColumn && source === lastSource) {
                    continue;
                }
                lastSourceLine = line;
                lastSourceColumn = column;
                lastSource = source;
                // Sigh, TypeScript can't figure out source/line/column are either all null, or all non-null...
                genMapping.addSegment(gen, i, genCol, source, line, column, name);
                if (content != null)
                    genMapping.setSourceContent(gen, source, content);
            }
        }
        return gen;
    }
traceMappings is only called on the root level SourceMapTree, and begins the process of
resolving each mapping in terms of the original source files.