filterByMode = (options, mode) => {
	const filterMode = options[mode];
	const parentMode = options[OptionParentMode];
	const rootSpec = options[OptionGetSpec];
	/** @type {*} */
	const output = {};
	for (const [key, value] of Object.entries(filterMode)) {
		if (typeof value === 'undefined') continue;
		const parentSpec = rootSpec[key];

		if (typeof value !== 'object') {
			output[key] = value;
		} else {
			if (!parentSpec.nest) {
				Object.assign(output, filterByMode(options[key], mode));

				if (typeof parentMode[mode][key] !== 'undefined') output[key] = parentMode[mode][key];
			} else {
				output[key] = {
					...filterByMode(options[key], mode)
				};
				if (`_${key}` in options) {
					output[`_${key}`] = parentMode[mode][key];
				}
			}
		}
	}

	return output;
}
@param {ReturnType<typeof Options>} options
@param {OptionSafeMode | OptionSecretMode} mode