Fixing the issue of buiding input/output trees upwards