Updated to properly inherit everything within key 'enc' from inherited nodes recursively, with the input node taking priority, and cleaned up functions