Recursively flattens a nested list into a single flat list containing only the leaf values, preserving left-to-right order.
Currently only lists are flattened and all other objects are treated as leaves.
Use build_tree() to capture the nesting structure so it can be restored with
unflatten().
Value
list() containing the flattened values.