private Node FindNodeWithSmallestF(List<Node> nodes) { int smallestF = nodes.Min(x => x.F); return nodes.FirstOrDefault(x => x.F == smallestF); }