//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Override @SuppressWarnings("unchecked") public java.util.Collection<org.neo4j.graphdb.Path> evaluate(org.neo4j.graphdb.traversal.TraversalBranch branch, org.neo4j.graphdb.Direction direction)
        public override ICollection <Path> Evaluate(TraversalBranch branch, Direction direction)
        {
            // [0] for paths from start, [1] for paths from end
            ICollection <TraversalBranch>[] pathsHere = _paths[branch.EndNode()];
            int index = direction.ordinal();

            if (pathsHere == null)
            {
                pathsHere = new System.Collections.ICollection[]
                {
                    new List <TraversalBranch>(),
                    new List <TraversalBranch>()
                };
                _paths[branch.EndNode()] = pathsHere;
            }
            pathsHere[index].Add(branch);

            // If there are paths from the other side then include all the
            // combined paths
            ICollection <TraversalBranch> otherCollections = pathsHere[index == 0 ? 1 : 0];

            if (otherCollections.Count > 0)
            {
                ICollection <Path> foundPaths = new List <Path>();
                foreach (TraversalBranch otherBranch in otherCollections)
                {
                    TraversalBranch startPath             = index == 0 ? branch : otherBranch;
                    TraversalBranch endPath               = index == 0 ? otherBranch : branch;
                    BidirectionalTraversalBranchPath path = new BidirectionalTraversalBranchPath(startPath, endPath);
                    if (IsAcceptablePath(path))
                    {
                        if (_returnedPaths.Add(path) && IncludePath(path, startPath, endPath))
                        {
                            foundPaths.Add(path);
                        }
                    }
                }

                if (foundPaths.Count > 0)
                {
                    return(foundPaths);
                }
            }
            return(null);
        }
 private bool IsAcceptablePath(BidirectionalTraversalBranchPath path)
 {
     return(_pathPredicate.test(path));
 }