Ensure empty elements are removed from the remainingPath array