public static boolean reachableByGhost(Game game, int nodeIndex, int timeLimit, EnumMap<GHOST, int[]> ghostJunctionPaths) {
		for (GHOST ghost : GHOST.values()) {
			// ghost is inside the lair
			if (game.getGhostLairTime(ghost) > 0) {
				int releaseTimeGhost = game.getGhostLairTime(ghost);
				int distanceGhostToNode = game.getShortestPathDistance(game.getGhostInitialNodeIndex(), nodeIndex);
				if (releaseTimeGhost + distanceGhostToNode <= timeLimit)
					return true;
			}

			// ghost is alive
			else if (game.getGhostLairTime(ghost) == 0) {
				int[] junctionPath = ghostJunctionPaths.get(ghost);
				int distanceToJunction = junctionPath.length - 1;
				int distanceJunctionToNode = game.getShortestPathDistance(junctionPath[junctionPath.length - 1], nodeIndex);
				int edibleTime = game.getGhostEdibleTime(ghost);

				// ghost is not edible
				if (edibleTime == 0) {					
					// test path to first junction
					for (int i = 0; i < junctionPath.length; i++) {
						if (junctionPath[i] == nodeIndex) {
							if (i <= timeLimit)
								return true;
						}
					}

					// test total needed time
					int totalTime = distanceToJunction + distanceJunctionToNode; 
					if (totalTime <= timeLimit)
						return true;
				}
			}
		}

		return false;
	}