Fix for keyerror in a system with multiple cycles.
Merge pull request #1866 from Kenneth-T-Moore/nested

Fix for keyerror in a system with multiple cycles.