/* The descend argument controls whether the first child is considered to be the next node. The top node argument constrains the walk to the node's children.  */
mxml_node_t* mxmlWalkNext(mxml_node_t *node, mxml_node_t *top, int descend)
/* The descend argument controls whether the first child is considered to be the next node. The top node argument constrains the walk to the node's children.  */
mxml_node_t* mxmlWalkNext(mxml_node_t *node, mxml_node_t *top, int descend)
{
  if (!node)
    return (NULL);
  else if (node->child && descend)
    return (node->child);
  else if (node == top)
    return (NULL);
  else if (node->next)
    return (node->next);
  else if (node->parent && node->parent != top)
  {
    node = node->parent;
    while (!node->next)
      if (node->parent == top || !node->parent)
        return (NULL);
      else
        node = node->parent;
    return (node->next);
  }
  else
    return (NULL);
}