code: private List<DefNode> flatten(DefNode node) {
          final List<DefNode> result = new ArrayList<>();
          result.add(node);
          return flatten(result, node.getChildren());
      }
docs: Flattens the hierarchical list of nodes.
  
  @param node the node with children to flatten
  @return the flattened list of nodes