# coding: utf-8


class Goals():
    def __init__(self, name):
        self.goals = {1: name}
        self.top_keys = set([1])
        self.transitions = dict()

    def add(self, name, add_to=1):
        next_id = len(self.goals) + 1
        self.goals[next_id] = name
        self.top_keys.add(next_id)
        if 1 in self.top_keys:
            self.top_keys.remove(1)
        self.transitions.setdefault(add_to, list())
        self.transitions[add_to].append(next_id)

    def all(self):
        return self.goals

    def top(self):
        return {key: self.goals[key]
                for key in self.top_keys
                if key not in self.transitions.keys()}

@@ -91,41 +91,8 @@
 me%7D%0A
-        self.top_keys = set(%5B1%5D)%0A
     
@@ -121,16 +121,16 @@
  dict()%0A
+
 %0A    def
@@ -234,110 +234,8 @@
 ame%0A
-        self.top_keys.add(next_id)%0A        if 1 in self.top_keys:%0A            self.top_keys.remove(1)%0A
     
@@ -470,16 +470,20 @@
 elf.
-top_
+goals.
 keys
+()
 %0A   

remove unneeded structure