public ArrayList<Node> CreateListFromBeginToMidle(Node middleNode) { ArrayList<Node> firstHalfList = new ArrayList<Node>(); Node actualNode = middleNode; while (actualNode != null) { firstHalfList.add(actualNode); actualNode = actualNode.getParentFromBeginNode(); } return reverseList(firstHalfList); }
public static ArrayList<Node> CreateListFromMiddleToEnd(Node middleNode) { ArrayList<Node> secondHalfList = new ArrayList<Node>(); Node actualNode = middleNode.getParentFromEndNode(); while (actualNode != null) { secondHalfList.add(actualNode); actualNode = actualNode.getParentFromEndNode(); } return secondHalfList; }