src/fn/Map.php
public function flatten(callable $mapper = null, string $glue = '/'): self
    {
        return $this->tree(function(Map\Path $it, $value) use($glue, $mapper) {
            $key = implode($glue, $it->keys);
            $mapper && $value = $mapper(...[$value, &$key, $it]);
            if ($value instanceof Map\Value) {
                return $value->key === null ? $value->andKey($key) : $value;
            }
            return $value === null ? $value : mapKey($key)->andValue($value);
        });
    }
public function flatten(callable $mapper = null, string $glue = '/'): self
    {
        return $this->tree(function(Map\Path $it, $value) use($glue, $mapper) {
            $key = implode($glue, $it->keys);
            $mapper && $value = $mapper(...[$value, &$key, $it]);
            if ($value instanceof Map\Value) {
                return $value->key === null ? $value->andKey($key) : $value;
            }
            return $value === null ? $value : mapKey($key)->andValue($value);
        });
    }
@param callable $mapper
@param string $glue

@return static