code: private int visit(boolean[] visited, int[] result, int p, int v, int n) {
          visited[v] = true;
          result[n++] = v;
          for (int w : adjList[v]) {
              if (w != p && !visited[w]) {
                  n = visit(visited, result, v, w, n);
              }
          }
          return n;
      }
docs: Recursively visit 'v' and all vertices adjacent to it (excluding 'p')
  adding them to the result array.
  
  @param visited visit flags array, should be cleared before search
  @param result  visited vertices
  @param p       previous vertex
  @param v       start vertex
  @param n       current number of visited vertices
  @return new number of visited vertices