Goldman Sachs Asset & Wealth Management systems may represent complex portfolio holdings as nested JSON containing account metadata, security details, and arrays of positions. Write a function that flattens this structure into a dictionary whose keys are dot-delimited paths to leaf values.
Implement flatten_holdings(holdings), where holdings is a JSON-compatible Python dictionary. Traverse nested dictionaries and lists recursively:
None, become output values.. characters, so dots can safely separate path components.Return a dictionary mapping each leaf path string to its original value. The root input is always a dictionary. An empty root dictionary returns an empty result.
def flatten_holdings(holdings):