Load Center as Junction Box

I have a 40 amp subpanel in detached shed. It was installed to code. It feeds off of 100amp subpanel in basement with 4 #8 conductors in a 75' 1.5" conduit. I have installed a generator inlet box on the side of the shed. I would like to use the same conduit to feed 4 #10 condutors back to the basement subpanel and then "through" it to a generator transfer panel that hangs next to it. Can I use the shed subpanel as a junction box to connect the power inlet box to the new set of 4 #10 condutors in the conduit, and then when it arrives back in the basement load center, can I simply have those 4 #10's "transit" though the box and out in to the gen trans switch next to it? Wasn't sure if NEC allows circuits that are not part of each load center to junction within, or transfer through those load centers. This would prevent having to break existing conduit with a T-Box to keep the generator conductors outside both boxes. Your guidance would be appreciated.