public static List<Node<Bytes>> decodeNodes(final Bytes location, final Bytes nodeRlp) {
    if (nodeRlp.equals(MerkleTrie.EMPTY_TRIE_NODE)) {
      return new ArrayList<>();
    }
    final Node<Bytes> node = decode(location, nodeRlp);
    final List<Node<Bytes>> nodes = new ArrayList<>();
    nodes.add(node);

    final List<Node<Bytes>> toProcess = new ArrayList<>(node.getChildren());
    while (!toProcess.isEmpty()) {
      final Node<Bytes> currentNode = toProcess.remove(0);
      if (Objects.equals(NullNode.instance(), currentNode)) {
        // Skip null nodes
        continue;
      }
      nodes.add(currentNode);

      if (!currentNode.isReferencedByHash()) {
        // If current node is inlined, that means we can process its children
        toProcess.addAll(currentNode.getChildren());
      }
    }

    return nodes;
  }
Flattens this node and all of its inlined nodes and node references into a list.

@param location The location in the trie.
@param nodeRlp The bytes of the trie node to be decoded.
@return A list of nodes and node references embedded in the given rlp.
ethereum/trie/src/main/java/org/hyperledger/besu/ethereum/trie/patricia/TrieNodeDecoder.java