Refine the script and use the outside lib.
Add input check when getting all nodes.