Converts a nested object to a plain object