getLeaves method

List<SimpleNode> getLeaves()

Implementation

List<SimpleNode> getLeaves() {
  List<SimpleNode> result = [];

  List<NodeV2> toCheck = [this];

  while (toCheck.isNotEmpty) {
    NodeV2 k = toCheck[0];
    toCheck.remove(k);

    if (k is SimpleNode) {
      result.add(k);
    } else {
      toCheck.addAll(k.children);
    }
  }

  return result;
}