def _get_gosrcs_upper(self, goids, max_upper, go2parentids):
        """Get GO IDs for the upper portion of the GO DAG."""
        gosrcs_upper = set()
        get_nt = self.gosubdag.go2nt.get
        go2nt = {g:get_nt(g) for g in goids}
        # Sort by descending order of descendant counts to find potential new hdrgos
        go_nt = sorted(go2nt.items(), key=lambda t: -1*t[1].dcnt)
        goids_upper = set()
        for goid, _ in go_nt: # Loop through GO ID, GO nt
            goids_upper.add(goid)
            if goid in go2parentids:
                goids_upper |= go2parentids[goid]
            #print "{} {:3} {}".format(goid, len(goids_upper), gont.GO_name)
            if len(goids_upper) < max_upper:
                gosrcs_upper.add(goid)
            else:
                break
        return gosrcs_upper
Get GO IDs for the upper portion of the GO DAG.