Gate class now stores ancestors. The addAncestor method is private and called from inside the class (addSuccessor is the method to use outside the class).