// GetBeginNodeID gets node id from last ancestor
if len(bi.Ancestors) == 0 {
// root branch
return 1
}
idx := len(bi.Ancestors) - 1
return bi.Ancestors[idx].GetEndNodeId()
}
if len(ans) > 0 {
// sort ans based onf EndNodeID so that we can set BeginNodeID
sort.Slice(ans, func(i, j int) bool { return (ans)[i].GetEndNodeId() < (ans)[j].GetEndNodeId() })