private List<Path> createThisHeadRoadPaths(Road head) { List<Path> paths = new ArrayList<Path>(); List<Road> headRoadEntrances = new ArrayList<Road>(); for (Road neighbourRoad : roadHelper.getConnectedRoads(head.getID())) { if (added.contains(neighbourRoad)) { continue; } else if (entrances.contains(neighbourRoad)) { added.add(neighbourRoad); headRoadEntrances.add(neighbourRoad); continue; } end = false; Path path = new Path(world); path.add(head); added.add(head); path.setHeadOfPath(head); createAPath(neighbourRoad, path); paths.add(path); added.remove(head); } if (!headRoadEntrances.isEmpty() && paths.size() > 0) { List<Road> temp = new ArrayList<Road>(); temp.addAll(paths.get(0)); paths.get(0).clear(); for (Road road : headRoadEntrances) { paths.get(0).add(road); paths.get(0).addEntrance(getEntrance(road)); } paths.get(0).addAll(temp); } return paths; }