code: private List<DefNode> flatten(List<DefNode> result, List<DefNode> nodes) {
          nodes.stream().forEach(n -> {
              flatten(result, n.getChildren());
              result.add(n);
          });
          return result;
      }
docs: Flattens the hierarchical list of nodes.
  
  @param result the results
  @param nodes the nodes
  @return the flattened list of nodes