/* If NextNode is not NULL, return the next node. */
STATIC EFI_STATUS EFIAPI AmlIteratorGetNextBranch(IN AML_TREE_ITERATOR *Iterator, OUT AML_NODE_HEADER **NextNode)
/* If NextNode is not NULL, return the next node. */
STATIC EFI_STATUS EFIAPI AmlIteratorGetNextBranch(IN AML_TREE_ITERATOR *Iterator, OUT AML_NODE_HEADER **NextNode)
{
  AML_TREE_ITERATOR_INTERNAL  *InternalIterator;
  AML_NODE_HEADER             *Node;
  InternalIterator = (AML_TREE_ITERATOR_INTERNAL *)Iterator;
  if ((InternalIterator == NULL)                              ||
      (InternalIterator->Mode != EAmlIteratorBranch)          ||
      !IS_AML_NODE_VALID (InternalIterator->InitialNode)      ||
      !IS_AML_NODE_VALID (InternalIterator->CurrentNode))
  {
    ASSERT (0);
    return EFI_INVALID_PARAMETER;
  }
  Node = AmlGetNextNode (InternalIterator->CurrentNode);
  if (AmlGetParent (Node) ==
      AmlGetParent ((AML_NODE_HEADER *)InternalIterator->InitialNode))
  {
    Node = NULL;
  }
  InternalIterator->CurrentNode = Node;
  if (NextNode != NULL) {
    *NextNode = Node;
  }
  return EFI_SUCCESS;
}