def walkFlattenFields(sigOrVal, skipPadding=True):
t = sigOrVal._dtype<EOL>if isinstance(t, Bits):<EOL><INDENT>yield sigOrVal<EOL><DEDENT>elif isinstance(t, HUnion):<EOL><INDENT>yield from walkFlattenFields(sigOrVal._val, skipPadding=skipPadding)<EOL><DEDENT>elif isinstance(t, HStruct):<EOL><INDENT>for f in t.fields:<EOL><INDENT>isPadding = f.name is None<EOL>if not isPadding or not skipPadding:<EOL><INDENT>if isPadding:<EOL><INDENT>v = f.dtype.fromPy(None)<EOL><DEDENT>else:<EOL><INDENT>v = getattr(sigOrVal, f.name)<EOL><DEDENT>yield from walkFlattenFields(v)<EOL><DEDENT><DEDENT><DEDENT>elif isinstance(t, HArray):<EOL><INDENT>for item in sigOrVal:<EOL><INDENT>yield from walkFlattenFields(item)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise NotImplementedError(t)<EOL><DEDENT>
Walk all simple values in HStruct or HArray