def find_next_joint(root, current_link, next_joint_name):
<EOL>has_next = False<EOL>next_joint = None<EOL>search_by_name = True<EOL>current_link_name = None<EOL>if next_joint_name is None:<EOL><INDENT>search_by_name = False<EOL>current_link_name = current_link.attrib["<STR_LIT:name>"]<EOL><DEDENT>for joint in root.iter("<STR_LIT>"):<EOL><INDENT>if search_by_name:<EOL><INDENT>if joint.attrib["<STR_LIT:name>"] == next_joint_name:<EOL><INDENT>has_next = True<EOL>next_joint = joint<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if joint.find("<STR_LIT>").attrib["<STR_LIT>"] == current_link_name:<EOL><INDENT>has_next = True<EOL>next_joint = joint<EOL>break<EOL><DEDENT><DEDENT><DEDENT>return has_next, next_joint<EOL>
Find the next joint in the URDF tree

Parameters
----------
root
current_link: xml.etree.ElementTree
    The current URDF link
next_joint_name: str
    Optional : The name of the next joint. If not provided, find it automatically as the first child of the link.