public Result dfs()
	{
		long startTime = System.currentTimeMillis();
		Deque<Node> stack = new ArrayDeque<Node>();
		Set<Node> set = new HashSet<Node>();

		int nodesProcessed = 0;

		stack.addFirst(initial);


		while(!stack.isEmpty())
		{

			Node temp = stack.removeFirst();
			nodesProcessed++;

			if(temp.getState().equals(finalState))
			{
				long endTime = System.currentTimeMillis();


				Deque<Grid.Direction> pathStack = new ArrayDeque<Grid.Direction>();
				pathStack.add(temp.getDirection());
				Node temp2 = temp.getParent();

				while(temp2.getParent() != null)
				{
					pathStack.addFirst(temp2.getDirection());
					temp2 = temp2.getParent();
				}

				StringBuilder pathTaken = new StringBuilder(pathStack.size());

				if(pathStack.peek().toString().equals(null))
				{

				}
				else
				{
					while(!pathStack.isEmpty())
					{

						pathTaken.append(pathStack.removeFirst().toString());
					}
				}

				return new Result(pathTaken.toString(), nodesProcessed, startTime-endTime);
			}
			if(!set.contains(temp))
			{
				set.add(temp);
				for(Node child : temp.successors())
				{
					stack.addFirst(child);
				}

			}
		}
		return null;
	}