private static ArrayList<MapEdge> createTree(int type, MapEdge start, MapEdge end) throws NullPointerException {
        MapNode fn1 = DataLoader.nodes.get(start.getFNode());
        Point2D.Double xy1 = new Point2D.Double(fn1.getX(), fn1.getY());
        MapNode tn2 = DataLoader.nodes.get(end.getTNode());
        Point2D.Double xy2 = new Point2D.Double(tn2.getX(), tn2.getY());
        Integer idStart;
        Integer idEnd;
        EdgeWeightedDigraph graph;

        if (type == 0) {
            graph = theGraph;
            idStart = nodesCar.get(xy1);
            idEnd = nodesCar.get(xy2);
        } else {
            graph = theGraph;
            idStart = nodesWalk.get(xy1);
            idEnd = nodesWalk.get(xy2);
        }

        if (idStart == null || idEnd == null || graph == null) {
            throw new NullPointerException("Could not find nodes in the HashMap.");
        }

        tree = new AstarSP(graph, idStart, idEnd);
        return shortestPath(idEnd);

    }