         guard let moc = managedObjectContext else {
             return Set<Action>()
         }
-        
+
         var nodes = [AnyObject]()
-//        var toFilter: Bool = false
         
         if let v = types {
             if let n = search(forEntityName: ModelIdentifier.actionName, types: v) {

        
        if let v = tags {
            if let n = search(forEntityName: ModelIdentifier.entityTagName, tags: v) {
//                toFilter = 0 < nodes.count
                nodes.append(contentsOf: n)
            }
        }
        
        if let v = groups {
            if let n = search(forEntityName: ModelIdentifier.entityGroupName, groups: v) {
//                toFilter = 0 < nodes.count
                nodes.append(contentsOf: n)
            }
        }
        
        if let v = properties {
            if let n = search(forEntityName: ModelIdentifier.entityPropertyName, properties: v) {
//                toFilter = 0 < nodes.count
                nodes.append(contentsOf: n)
            }
        }
        
//        if toFilter {
//            var seen = [String: Bool]()
//            var i: Int = nodes.count - 1
//            while 0 <= i {
//                if let v = nodes[i] as? ManagedEntity {
//                    if nil == seen.updateValue(true, forKey: v.id) {
//                        nodes[i] = Entity(managedNode: v)
//                        i -= 1
//                        continue
//                    }
//                } else {
//                    let n = nodes[i]["node"]
//                    var c: Bool? = false
//                    var weakNodes: [Any]? = nodes
//                    moc.performAndWait { [unowned moc] in
//                        if let v = moc.object(with: n! as! NSManagedObjectID) as? ManagedEntity {
//                            if nil == seen.updateValue(true, forKey: v.id) {
//                                weakNodes?[i] = Entity(managedNode: v)
//                                i -= 1
//                                c = true
//                            }
//                        }
//                    }
//                    if true == c {
//                        continue
//                    }
//                }
//                nodes.remove(at: i)
//                i -= 1
//            }
//            return nodes as! [Entity]
//        }
        
        var set = Set<Entity>()
        nodes.forEach { [weak moc] in

        
        if let v = tags {
            if let n = search(forEntityName: ModelIdentifier.relationshipTagName, tags: v) {
                nodes.append(contentsOf: n)
            }
        }
        
        if let v = groups {
            if let n = search(forEntityName: ModelIdentifier.relationshipGroupName, groups: v) {
                nodes.append(contentsOf: n)
            }
        }
        
        if let v = properties {
            if let n = search(forEntityName: ModelIdentifier.relationshipPropertyName, properties: v) {
                nodes.append(contentsOf: n)
            }
        }
        
        var set = Set<Relationship>()
        nodes.forEach { [weak moc] in
