print top n nodes in proper order