def lookup target, *arg
			output = arg[0] ? arg[0] : Array.new
			node = @root

			# If this is a string process each character
			if String(target) == target
				target.each_char do |char|
					# Follow the failures until a goto transition is found
					# or we return to the root node.
					while(!node.goto(char) and !node.eql? @root)
						node = node.failure
					end

					# If there is a goto transition follow it; otherwise, 
					# we can assume we are at the root node.
					if node.goto(char)
						node = node.goto(char)

						if node.output		
							if block_given?
								output = yield output, node.output
							else
								output = output + node.output
							end
						end

					end
				end
			else # Otherwise, target should support "each" method.
				for item in target
					# Follow the failures until a goto transition is found
					# or we return to the root node.
					while(!node.goto(item) and !node.eql? @root)
						node = node.failure
					end

					# If there is a goto transition follow it; otherwise, 
					# we can assume we are at the root node.
					if node.goto(item)
						node = node.goto(item)

						if node.output		
							if block_given?
								output = yield output, node.output
							else
								output = output + node.output
							end
						end

					end
				end
			end

			return output
		end
def lookup target, *arg
			output = arg[0] ? arg[0] : Array.new
			node = @root

			# If this is a string process each character
			if String(target) == target
				target.each_char do |char|
					# Follow the failures until a goto transition is found
					# or we return to the root node.
					while(!node.goto(char) and !node.eql? @root)
						node = node.failure
					end

					# If there is a goto transition follow it; otherwise, 
					# we can assume we are at the root node.
					if node.goto(char)
						node = node.goto(char)

						if node.output		
							if block_given?
								output = yield output, node.output
							else
								output = output + node.output
							end
						end

					end
				end
			else # Otherwise, target should support "each" method.
				for item in target
					# Follow the failures until a goto transition is found
					# or we return to the root node.
					while(!node.goto(item) and !node.eql? @root)
						node = node.failure
					end

					# If there is a goto transition follow it; otherwise, 
					# we can assume we are at the root node.
					if node.goto(item)
						node = node.goto(item)

						if node.output		
							if block_given?
								output = yield output, node.output
							else
								output = output + node.output
							end
						end

					end
				end
			end

			return output
		end
Finds all occurrences of patterns in the Trie contained in target.
 Outputs an array of patterns contained within the target.

 Accepts an optional argument to override the type of the output (e.g. String.new)
 Accepts an optional block that can modify how the output is built from each node.