/// <summary> /// Inverts the node heritage. /// </summary> /// <param name="basePath">The base path.</param> /// <param name="invertedPath">The inverted path.</param> /// <returns>The complete path</returns> private BaseNode InvertNodeHeritage(BaseNode basePath, BaseNode invertedPath) { if (invertedPath != null) { BaseNode newInvertedPath = invertedPath.Parent; BaseNode newBasePath = new BaseNode( invertedPath.X, invertedPath.Y, invertedPath.CrateLocations, this.CalculatePathCost(basePath, TreeHelpers.DetermineMove(basePath.X, basePath.Y, invertedPath.X, invertedPath.Y), invertedPath.CrateLocations), this.CalculateHeuristicValue(basePath, TreeHelpers.DetermineMove(basePath.X, basePath.Y, invertedPath.X, invertedPath.Y), invertedPath.CrateLocations), basePath, TreeHelpers.DetermineMove(basePath.X, basePath.Y, invertedPath.X, invertedPath.Y)); return(this.InvertNodeHeritage(newBasePath, newInvertedPath)); } return(basePath); }