         if resultSet[key]?
           continue
         # ignore nodes in the source set
-        if xsSet[key]?
+        if xs.has key
           continue
         allParentsIn = true
         for parentValue of child.parents
-          unless xsSet[parentValue]?
+          unless xs.has parentValue
             allParentsIn = false
             break
         resultSet[key] = allParentsIn

    return results

  # find those elements whose children are all in xs
  # O(xs.length)
  Graph.prototype.whereAllChildrenIn = (xs) ->
    # dont inherit from the Object prototype such that we dont need to use hasOwnProperty
    xsSet = Object.create(null)
    # for fast lookup
    for x in xs
      xsSet[x] = true
    # dont inherit from the Object prototype such that we dont need to use hasOwnProperty
    resultSet = Object.create(null)
    for x in xs
      node = this.nodes[x]
      unless node?
        throw new Error "searching whereAllChildrenIn of `#{x}` which is not in graph"
      for key, parent of node.parents

        if resultSet[key]?
          continue
        # ignore nodes in the source set
        if xs.has key
          continue
        allChildrenIn = true
        for childValue of parent.children
          unless xs.has childValue
            allChildrenIn = false
            break
        resultSet[key] = allChildrenIn
