public void GetParentPath(GridItem node, GridItem start) { int nx = (int)node.GetGridPos().x; int ny = (int)node.GetGridPos().y; int sx = (int)start.GetGridPos().x; int sy = (int)start.GetGridPos().y; if (gridItems[nx, ny] == gridItems[sx, sy]) { originalPath.Add(currentPath); currentPath = new List <GridItem> (); return; } List <GridItem> nodePath = node.GetPath(); if (gridItems[nx, ny] != gridItems[sx, sy]) { currentPath.Add(nodePath[0]); } GetParentPath(nodePath[0], start); }