}
/** add forward or backward tiles to the beginning or end of path respectively */
private void addTiles(LinkedList<TilePlacement> newList, Location outLocation,
TilePlacementList remaining, Tantrix tantrix, boolean forward) {
TilePlacement nextPlacement = tantrix.get(outLocation);
if (nextPlacement != null && !newList.contains(nextPlacement) && !remaining.isEmpty()) {
if (forward)
newList.addLast(nextPlacement);
else {
newList.addFirst(nextPlacement);
}
remaining.remove(nextPlacement);
Collection<Location> outgoing = nextPlacement.getOutgoingPathLocations(primaryPathColor_).values();
for (Location loc : outgoing) {
addTiles(newList, loc, remaining, tantrix, forward);
}
}
}